我怎样才能获得的ErrorDocument在.htaccess输出错误的URI参数?

编程入门 行业动态 更新时间:2024-10-25 10:30:35
本文介绍了我怎样才能获得的ErrorDocument在.htaccess输出错误的URI参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我工作,围绕解决方案通过ErrorDocument来把所有的URI到一个页面。

I've worked-around the solution to transform all uri to one page via ErrorDocument.

这背后的原因是发送文件和文件夹(好的URL)的一页。不过,我需要的URI字符串被发送到index.php?URI =字符串。通过的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?

所以,我需要重写

www.something/games/specific-game

www.something/index.php ?URI = /游戏/特定游戏

这是可能在所有的,如果,怎么办?

Is this possible at all, if, how?

推荐答案

如果您的服务器支持服务器端包含(SSI),那么您使用以下 404.shtml 作为你的ErrorDocument:

If your server supports server-side include (SSI) then you use the following 404.shtml as your ErrorDocument:

<html> <header> <meta http-equiv="Refresh" content="0; url=/index.php?uri=<!--#echo var="REQUEST_URI" -->"> </header> </html>

编辑:还有一个更简单的方法:创建一个PHP文件作为您的ErrorDocument,你可以在它在阳光下做任何事情! :)

there is a simpler way: create a PHP file as your ErrorDocument and you can do anything under the sun in it! :)

EDIT2:您可以通过访问原始的URI $ _ SERVER ['REQUEST_URI']

you can access the original URI using $_SERVER['REQUEST_URI']

EDIT3:哎呀,如果你只是重定向到的index.php 在同一台主机上,你可以设置的index.php 文件作为您的ErrorDocument和检测,如果该请求是从404错误检查重定向,如果 $ _ SERVER ['REDIRECT_STATUS'] =='404'

heck, if you are just redirecting to index.php on the same host, you can just set that index.php file as your ErrorDocument and detect if the request is redirected from 404 error by checking if $_SERVER['REDIRECT_STATUS'] == '404'

更多推荐

我怎样才能获得的ErrorDocument在.htaccess输出错误的URI参数?

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

发布评论

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

>www.elefans.com

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