Rewrite all queries to not need the .php extension using a mod_rewrite RewriteRule
问题 I'd like all queries like http://mysite.com/something/otherthing?foo=bar&x=y to be rewritten as http://mysite.com/something/otherthing.php?foo=bar&x=y In other words, just make the .php extension optional, universally. 回答1: I would do it this way. Basically, if file doesn't exist, try adding .php to it. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)$ $1.php [QSA,L] 回答2: If you can change the httpd.conf and what to, you can also put: ForceType