1
我有旧网址是这样的:使用国防部重写重定向,使用查询字符串值与字符替换
http://www.foo.org/cgi-bin/search.cgi?Blog=14&tag=my%20long%20tag%20name&limit=100
,我想重定向到另一台服务器的页面,如:
http://www.bar.org/tag/my-long-tag-name/
于foo .org我有:
RewriteCond %{QUERY_STRING} ^Blog=14&tag=([^&]*)&.*$ [NC]
RewriteRule ^cgi-bin/search.cgi$ http://www.bar.org/tag/%1/? [NC,R=301,L]
这将重定向到bar.org上的正确页面,我需要将%20
用连字符。但是,它每%20
更改为%2520
。我试过添加NE
的标志,但没有改变。 这是我坚持的东西。
一旦出现,这个规则取代%20
s的连字符:
RewriteRule ^blog/tag/([^\s]*)(?:\s)+(.*)/$ /blog/tag/$1-$2/ [R=301,L]
(加分......其中一些原始tag
值也有%28
和他们%29
,最终我想。删除所以bob%20and%20%28thelma%29
标签变得bob-and-thelma
)
anubhava真是太棒了!非常感谢!我只是了解这是如何工作,但永远不会到达那里。有一件事 - 在第4行中,'tag /%1?'之前应该有'/'。再次感谢。 –
其实我在测试中有'RewriteBase /',这就是为什么我不需要''''tag'之前'但是现在修改了 – anubhava