如何找到引用网址,而使用htaccess的404重定向? [英] How to find referrer URL while using htaccess 404 redirect?
问题描述
我用code下面创建一个自定义的404消息(找不到网页)使用.htaccess文件。
RewriteEngine叙述在
ErrorDocument的404 https://开头%{HTTP_HOST} /404.php
它工作得很好,但我想知道那是什么导致这种重定向错误的URL。换句话说,我需要获取的 HTTP引用,而用户在404.php。所以,我已经使用 $ _ SERVER ['HTTP_REFERER']
在404.php,但它不会返回任何东西。结果
我在哪里有错?什么是您的解决方案来解决这一问题?
删除的http://
从404处理器,并有这样的:
的ErrorDocument 404 /404.php
这导致404的URL提供给您的 404.php
使用:
$ _ SERVER [REQUEST_URI]
在 HTTP:在404处理器服务器使用//
ISE进行全面重定向和你失去原来的 REQUEST_URI
<。 / p>
I've used the code below to create a custom 404 message (page not found) using a .htaccess file.
RewriteEngine On
ErrorDocument 404 https://%{HTTP_HOST}/404.php
It works well, but I want to know what was the wrong URL that caused this redirection. In other words, I need to fetch HTTP referer while user is in 404.php. So I have used $_SERVER['HTTP_REFERER']
in 404.php, but it does not return anything.
Where did I have mistakes? And what is your solutions to solve this problem?
Remove http://
from 404 handler and have it like this:
ErrorDocument 404 /404.php
The URL that is causing 404 is available to you in 404.php
using:
$_SERVER["REQUEST_URI"]
When http://
ise used in 404 handler server performs full redirection and you loose original REQUEST_URI
.
这篇关于如何找到引用网址,而使用htaccess的404重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!