.htacces RewriteRule空格和特殊字符

时间:2015-08-31 14:28:25

标签: .htaccess mod-rewrite special-characters

我想重定向我的旧网址:

http://www.example.com/oldurl/name-%20(page.php?a=34

到这个网址:

http://www.example.com/newurl/

关于重定向网址的大多数问题都在回答我的问题部分,例如如何使用"%20"。但我不知道如何一次性使用这个。

1 个答案:

答案 0 :(得分:1)

您可以在root .htaccess中使用此规则:

RewriteEngine On

RewriteCond %{QUERY_STRING} ^a=34$ [NC]
RewriteRule "^oldurl/name-(?:[ \s]|\x20)\(page\.php$" /newurl/? [L,NC,R=301]