Rewrite all queries to not need the .php extension using a mod_rewrite RewriteRule

前端 未结 5 716
情歌与酒
情歌与酒 2020-12-03 13:03

I\'d like all queries like

http://mysite.com/something/otherthing?foo=bar&x=y

to be rewritten as

http://mysite.com/some         


        
5条回答
  •  旧时难觅i
    2020-12-03 13:39

    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]
    

提交回复
热议问题