我怎样才能获得的ErrorDocument在.htaccess输出错误的URI参数? [英] How can I get ErrorDocument in .htaccess to output wrong uri parameter?

查看:130
本文介绍了我怎样才能获得的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?

所以,我需要重写

http://www.something.com/games/specific-game

http://www.something.com/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参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆