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

  • Home
  • SEARCH
  • 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 8599945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:30:25+00:00 2026-06-12T01:30:25+00:00

Possible Duplicate: PHP redirect based on IP AND referrer is it possible to redirect

  • 0

Possible Duplicate:
PHP redirect based on IP AND referrer

is it possible to redirect a user if they access the site from another location, what i want to do is when the user access the site from google, he will be redirected to the main site, but if he accessed the website from the link that came from the “main site” , a pop up window will appear that contains the restricted site, but since the user came from the “main site” he will be granted access.

any php or javascript will do, as long as it will check if the user came from the main site.

or if possible check from what “IP” the user came from to grant access?

  • 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-06-12T01:30:27+00:00Added an answer on June 12, 2026 at 1:30 am

    Redirecting the user can be accomplished using the header() method and setting a “Location: ” header for the new target. The conditional can be expressed by evaluating the Referer Header send by the client, this should be available in one of the PHP system variables, see http://php.net/manual/en/reserved.variables.server.php

    Something along the lines of:

    if (preg_match("/your-domain/",$_SERVER['HTTP_REFERER']) {
      header('Location: /hidden_page.html');
    } else {
      header('Location: /');
    }
    

    should do the trick.

    To redirect the google bot and that actions’ implications see Does Google bot crawl entire site if there is a redirect and http://forums.digitalpoint.com/showthread.php?t=1210

    For figuring out what’s inside the variables and how to use regular expressions in PHP, use this example code

    <pre>
    <?php 
        echo $_SERVER['HTTP_REFERER']."\n";
        echo $_SERVER['REMOTE_ADDR']."\n";
    
    if (preg_match("/188.174.82.97/",$_SERVER['REMOTE_ADDR'])) {
            echo "Yes";
        } else {
            echo "No";
        }
    ?>
    </pre>
    

    in your script or something like phpfiddle.org

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: PHP remove special character from string I want to find a regex
Possible Duplicate: How to redirect by using jquery? In my site I want to
Possible Duplicate: PHP page redirect how do i redirect to another page in php,
Possible Duplicate: PHP create a file without fopen I want to create a file
Possible Duplicate: Cookies aren't persisting in PHP? My objective is: when a user visits
Possible Duplicate: PHP - opendir on another server Something like this: opendir(http://super.cdn.com/running_order_image/sale/587/) The opendir
Possible Duplicate: php regex , extract phone number from text/html I have following requirement.
Possible Duplicate: How to make a redirect in PHP? Hi! How do i forward
Possible Duplicate: How to redirect users to another page? I'm a beginner in the
Possible Duplicate: PHP - send file to user I have written a script that

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.