Apache .htaccess: How to remove question mark from URL if not `?id=(.*)`?

后端 未结 2 602
暖寄归人
暖寄归人 2021-01-07 04:22

How to make .htaccess to remove question mark from URL if not ?id=(.*)?

# Rewrite for ?id=(.*)
RewriteCond %{Q         


        
2条回答
  •  臣服心动
    2021-01-07 05:05

    Does this work?

    RewriteCond %{QUERY_STRING} ^.+$
    RewriteCond %{QUERY_STRING} !^id=
    RewriteRule ^(.*)$ $1?%1 [R=301,L]
    

    Tip: during your testings, use 302 redirections instead of 301, as 301 redirections are stored by browsers. You can finally switch to classic 301 when you are done testing.

提交回复
热议问题