如何让 .htaccess 中的 ErrorDocument 输出错误的 uri 参数?
我已经解决了通过 ErrorDocument 将所有 uri 转换为一页的解决方案。
这背后的原因是将文件和文件夹(好的网址)发送到一页。但是,我需要将 URI 字符串发送到 index.php?uri=string 。这可以通过 ErrorDocument 实现吗?或者我该如何做到这一点?
所以我需要重写
到
http://www.something.com/index.html php?uri=/games/special-game
这是否可能,如果,如何?
I've worked-around the solution to transform all uri to one page via ErrorDocument.
The reason behind this is to send Files AND folders (nice urls) to one page. However, I need the URI string to be sent to index.php?uri=string . Is this possible via ErrorDocument, or how do I do this?
So I need to rewrite the
to
Is this possible at all, if, how?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的服务器支持服务器端包含(SSI),那么您可以使用以下
404.shtml
作为您的ErrorDocument:编辑:有一个更简单的方法:创建一个PHP文件作为您的ErrorDocument,您可以做任何事情在阳光下吧! :)
EDIT2:您可以使用
$_SERVER['REQUEST_URI']
访问原始 URIEDIT3:哎呀,如果您只是重定向到同一主机上的
index.php
,您只需将该index.php
文件设置为您的 ErrorDocument,并通过检查$_SERVER['REDIRECT_STATUS'] == '404'
If your server supports server-side include (SSI) then you use the following
404.shtml
as your ErrorDocument:EDIT: there is a simpler way: create a PHP file as your ErrorDocument and you can do anything under the sun in it! :)
EDIT2: you can access the original URI using
$_SERVER['REQUEST_URI']
EDIT3: heck, if you are just redirecting to
index.php
on the same host, you can just set thatindex.php
file as your ErrorDocument and detect if the request is redirected from 404 error by checking if$_SERVER['REDIRECT_STATUS'] == '404'