在localhost帮助中的htaccess

时间:2011-02-17 11:50:45

标签: .htaccess mod-rewrite

我的网址是这样的

localhost/luz/home -> read home.php file
localhost/luz/content/about -> read content.php?page=about

但不知怎的,它不能完全发挥作用。

localhost/luz/home -> SUCCESS
localhost/contenttt -> internal server error (contenttt.php doesn't exist and the 404 doesn't work)
localhost/content/about -> somehow it loads content.php?page=about.php/about

我的htaccess很简单

RewriteCond %{SCRIPT_FILENAME} !-d  
RewriteCond %{SCRIPT_FILENAME} !-f  
RewriteRule ^(.*)$ $1.php
RewriteRule ^content/(.*)$  content.php?page=$1
ErrorDocument 404 /404.php

1 个答案:

答案 0 :(得分:1)

您应该检查替换是否实际引用了现有文件:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php

否则,您将获得无限递归,每次最后添加.php