mod_rewrite with spaces in the urls

后端 未结 5 1970
野性不改
野性不改 2020-12-09 08:03

I need to set up some RewriteRules to redirect a URL which has a space in it. I\'ve tried this:

RewriteRule ^article/with%20spaces.html$ /article/without_spa         


        
5条回答
  •  感情败类
    2020-12-09 08:04

    If you want to avoid the complexity of escaping each space (e.g. if you plan to have this file automatically generated), you can simply use quotes:

    RewriteRule "^article/with spaces.html$" /article/without_spaces.html [R=301,L]
    

    Furthermore, these quotes can be used to encase any one expected argument:

    RewriteRule "^article/with spaces.html$" "/article/without_spaces.html" [R=301,L]
    

提交回复
热议问题