How to remove from url with .htaccess

前端 未结 2 1929
闹比i
闹比i 2021-01-22 18:28

how to remove %20,:,/,? and many more from url with .htaccess? im already try code from this post, but still not replace/redirect to new url .htaccess url rewrite and removing %

2条回答
  •  迷失自我
    2021-01-22 19:30

    You can add these 2 rules before your last rewrite rule:

    # replace %20 and / in QUERY_STRING by hyphen
    RewriteCond %{QUERY_STRING} "^([^/]*?)(?:/|%20)+([^/]+?(?:/|%20)+.*)$"
    RewriteRule ^ %{REQUEST_URI}?%1-%2 [N,NE]
    
    RewriteCond %{QUERY_STRING} "^([^/]*?)(?:/|%20)+([^/]+?)/?$"
    RewriteRule ^ %{REQUEST_URI}?%1-%2/ [L,R=302,NE]
    

提交回复
热议问题