PHP code to determine if a user was 301 redirected to my site

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

So in <strong></strong> I have a 301 redirect in the .htaccess file to <strong></strong>.

Can I place some PHP code in <strong></strong> 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 :-)


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

    <li>User enters in address bar and 301 redirected to
      <li>referer = ""</li> </ul></li> <li>User is visiting, clicks a link pointing to and 301 redirected to
        <li>referer = ""</li> </ul></li> </ul>

        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:

            <li></li> </ul></li> <li> and</li> <li>
              <li></li> </ul></li> </ul>

              人吐槽 人点赞



用户名: 密码:
验证码: 匿名发表


查看评论:PHP code to determine if a user was 301 redirected to my site