Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6891903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:28:05+00:00 2026-05-27T06:28:05+00:00

I have a mobile website and I am redirecting mobile users from main website

  • 0

I have a mobile website and I am redirecting mobile users from main website to mobile website. But I have also given option on my mobile website that if some mobile user want to visit the main website he can. To solve the problem I wrote this code on my main website

if (is_mobile()== true) //if user is browsing from mobile
{

    $main_website_url= 'http://localhost/www/redsignal/';   // main website URL

    $mobilesite_url = 'http://localhost/www/redsignal-mobile/';  //mobile website URL

    $mobilesite_url_length = strlen($mobilesite_url);

    $referring_path_url = substr($_SERVER['HTTP_REFERER'], 0 , $mobilesite_url_length);

    if ($referring_path_url == $mobilesite_url) //This if condition checks that if the mobile user is coming from my mobile website or not
    {
        header("Location:".$main_website_url);  // if he is coming from mobile he will be redirected to main website                
    }
    else
    {
        header("Location:".$mobilesite_url); // if not than he will be redirected to mobile website     
    }


}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:28:05+00:00Added an answer on May 27, 2026 at 6:28 am

    You need to use another variable in order to distinguish whether you want to force show original site when click on visit original site in mobile site. For this u can pass GET variable for e.g.

    http://localhost/www/redsignal/?force_show_original=1

    Then in your code you change this

    if (is_mobile()== true)
    

    to

    if (is_mobile()== true || $GET["force_show_original"] == true)
    

    let me know whether it worked

    UPDATE

    Use following code to redirect site

    if (is_mobile()== true || $GET["force_show_original"] == false) {
           //redirect to mobile site
    }
    else if(is_mobile()== true || $GET["force_show_original"] == true) {
           // redirect to original site
    }
    else {
           // redirect to original site
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a mobile website and I want users with authorized devices to visit
I have a mobile website form that I want to add type attributes to
I have my website automtically redirecting to a mobile version if the user has
I have a mobile website that allows users to upload photos using the file
I have put together a mobile website for us, and have the main site,
I want to have a mobile-friendly website, in addition to a native app for
I have a jquery mobile website that has simple select. I have successfully tested
I have a website ready but it doesnt look too good on a mobile
I am developing a WAP/mobile website that would allow users to stream audio/video (although
I'm creating a simple mobile website to render specifically on iPhone. I have been

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.