【发布时间】:2017-07-06 17:53:20
【问题描述】:
当在 URL 栏中输入 http://www.example.org/aa/doesntexist.php 时,我试图让 .htaccess 获取页面 http://www.example.org/aa/exists.php。 .htaccess 文件显然可以正常工作,因为 DirectoryIndex 行正在产生所需的结果,URL 栏中的 http://www.example.php 获取页面 http://www.example.php/aa/default.php。
我尝试根据我的情况调整对how to redirect using HTTP_REFERER on htaccess 的回复,但没有成功。
以下是我的.htaccess 文件的全文。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_REFERER} ^(.*)www\.example\.org/aa/doesntexist\.php [NC]
RewriteRule ^(.*)(www\.example\.org/aa/)doesntexist\.php(.*)$ $1$2exists.php$3 [NC,L]
DirectoryIndex aa/default.php
</IfModule>
对http://www.example.org/aa/doesntexist.php 的请求会产生以下错误:
找不到
在此服务器上找不到请求的 URL /aa/doesntexist.php。
此外,在尝试使用 ErrorDocument 处理请求时遇到 404 Not Found 错误。
【问题讨论】:
标签: apache .htaccess mod-rewrite http-referer