我试图让浏览器重定向,只要用户在/index.php
或/index.php/
或/index.php////
中键入简单的/
即可。这是我到目前为止php从/index.php重定向到/
if ($_SERVER['ORIG_PATH_INFO'] == '/index.php') {
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://'.$_SERVER['HTTP_HOST'].'/'
}
但是我得到一个无限循环重定向错误。我究竟做错了什么?有什么办法可以做到这一点?
编辑,似乎改变'ORIG_PATH_INFO'
到'REQUEST_URI'
做的伎俩/index.php
我该怎么添加到我的if
照顾index.php/
和index.php////
...?
您重定向的index.php到/这意味着同样的事情 – safarov 2012-03-18 12:50:01
@safarov出现搜索
index.php
:是的,但它会在地址栏更好,并且出于航行原因我需要它。 – qwertymk 2012-03-18 12:52:12你也可以用.htaccess文件来做。如果你想我可以写U带htaccess的 – safarov 2012-03-18 12:56:15