阿帕奇的.htaccess 404错误重定向

编程入门 行业动态 更新时间:2024-10-27 04:30:28
本文介绍了阿帕奇的.htaccess 404错误重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图让一个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错误重定向

本文发布于:2023-10-31 19:20:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1547037.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   阿帕奇   错误   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!