我试图让一个htaccess文件,将通过index.php文件重定向所有404错误。我想用户无法访问附加到index.php文件的URL的网页,这样我可以找出哪些页面请求失败。
I'm trying to make an htaccess file that will redirect all 404 errors through index.php. I would like the page the user failed to access to be appended to index.php's URL so that I can find out what page request failed.
例如,如果他们试图访问 example/doesntexist.php ,阿帕奇应该重定向到 example/index.php/doesntexist
For example, if they tried to access example/doesntexist.php, apache should redirect them to example/index.php/doesntexist
这是我有:
RewriteCond %{REQUEST_FILENAME} !-l RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule .* index.php?%{QUERY_STRING} [L]这工作对我的主机商之一,但失败了,当我转移网站到另一个虚拟主机提供商(GoDaddy的)。
This works on one of my webhosts but failed when I transfered the site to another webhost (GoDaddy).
谢谢你们
推荐答案我现在还不能测试这一权利,但根据this回答,当你设置一个
I can't test this right now, but according to this answer, when you set a
ErrorDocument /404.php
(或index.php文件,无所谓)
(or index.php, doesn't matter)
在 $ _ SERVER [REQUEST_URI] 变量将包含原始,失败的请求。
The $_SERVER["REQUEST_URI"] variable will contain the original, failed request.
更多推荐
阿帕奇的.htaccess 404错误重定向
发布评论