【发布时间】:2014-04-03 12:51:08
【问题描述】:
我在.htaccess文件中使用下面的代码来隐藏php文件的扩展名。
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ ([^\.]+)$ $1.php [NC]
我把这个文件放在localhost/obis/
但是当我运行没有.php扩展名的index.php文件时,会出现以下错误。
The requested URL /obis/index was not found on this server.
谁能提出可能是什么错误?
我从本教程中获取了代码:http://www.youtube.com/watch?v=L6k_WvvpPpk
【问题讨论】:
-
我已经检查过了,但它没有给我一个可行的解决方案。
-
^ ([^\.]+)$ $1.php [NC]有空格,应该是^([^\.]+)$ $1.php [NC] -
不,它不工作!
-
试试这个
RewriteRule ^(.*)([^\.]+)$ $1$2.php [NC]
标签: php regex apache .htaccess mod-rewrite