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 7571527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:41:45+00:00 2026-05-30T15:41:45+00:00

Is it possible in PHP to know if a user has been 301 redirected

  • 0

Is it possible in PHP to know if a user has been 301 redirected to my website?

So in myoldsite.com I have a 301 redirect in the .htaccess file to mynewsite.com.

Can I place some PHP code in mynewsite.com to recognise when a user has been 301 redirected? I just need this to display a specific message if this is the case.

Many thanks for any pointers here 🙂

  • 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-30T15:41:46+00:00Added an answer on May 30, 2026 at 3:41 pm

    I believe with 301-redirects the HTTP_REFERER field will contain the original referer:

    • User enters oldsite.com in address bar and 301 redirected to newsite.com
      • referer = “”
    • User is visiting 3rdparty.com, clicks a link pointing to oldsite.com and 301 redirected to newsite.com
      • referer = “3rdparty.com”

    This behavior somewhat makes sense for 301 redirects.

    Solution: I think you should add a query-string parameter to your 301 response such as ref=oldsite and check its value on your new website.

    If you are concerned about having query string parameters in your URLs, you can tell search engines to ignore specific query string parameters. The procedure varies with search engines. Apparently there is a trick that works across all major search engines: the <link rel="canonical"> tag. Examples:

    • http://newsite.com/?ref=oldsite
      • http://newsite.com/
    • http://newsite.com/?ref=oldsite&page=main and
    • http://newsite.com/?page=main&ref=oldsite
      • http://newsite.com/?page=main
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this topic has been discussed a lot , but I have a
Possible Duplicate: PHP: Script for generating Crossword game? Does anyone know any PHP-based simple
I know that it's not possible to style any given PHP but I do
I'm new to PHP programming and I wanted to know that is it possible
Possible Duplicate: php multi-dimensional array remove duplicate I have an array like this: $a
Now I have my website built on PHP & Mysql. Consider this like a
I've been doing some web development work in PHP recently which has led me
I know questions like this have been asked numerous times, but not quite this
The user has just chosen a file for upload using the HTML File input
Possible Duplicate: PHP detecting request type (GET, POST, PUT or DELETE) This should be

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.