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

后端 未结 2 600
暖寄归人
暖寄归人 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:18

    This would be the right rule:

    RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^?#\ ]*)\?[^\ ]*\ HTTP/ [NC]
    RewriteCond !{QUERY_STRING} id
    RewriteRule .*$ %{REQUEST_URI}? [R=301,L]
    

    Update:

    # Query rewrite exceptions
    RewriteCond %{QUERY_STRING} !callback=.*
    

提交回复
热议问题