remove query string from end of URL using .htaccess

后端 未结 2 1116
攒了一身酷
攒了一身酷 2020-12-06 13:53

I\'m trying to remove string from the end of URL:

For example i have a structure like this:

http://sitename.com/category/first-category-name/?post_ty         


        
2条回答
  •  隐瞒了意图╮
    2020-12-06 14:19

    Just do something like this:

    RewriteEngine On
    RewriteBase /
    # Make sure there is a query string
    RewriteCond %{QUERY_STRING} .
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .*  /? [R=301,L]
    

    Place a ? at the end to remove the query when present.

提交回复
热议问题