My url is something like this
localhost/luz/home -> read home.php file
localhost/luz/content/about -> read content.php?page=about
But somehow it doesn't work completely.
loc开发者_如何学Pythonalhost/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
My htaccess is simple
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ $1.php
RewriteRule ^content/(.*)$ content.php?page=$1
ErrorDocument 404 /404.php
You should check if the substitution actually references an existing file:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php
Otherwise you will get an infinite recursion that adds .php
at the end every time.
精彩评论