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

前端 未结 5 718
情歌与酒
情歌与酒 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条回答
  •  被撕碎了的回忆
    2020-12-03 13:34

    This works:

    RewriteCond %{QUERY_STRING} ^.+$
    RewriteRule ^/?([^/\.]+)$ /$1.php [L]
    

    The idea is to make sure there's a query string (question mark plus stuff) and if so check if the stuff before the question mark has no extension and if so, append .php.

提交回复
热议问题