2012-05-03 66 views
0

我从我写的一个现在停止的教程每天都有几个命中。我没有让他们坐在404上,而是创建了一个链接到更新的链接的页面,希望别人能够提供帮助。HTACCESS从URL重定向包括?到静态页面

我试图编辑我的htaccess到rediret

我的网站是WP供电,收到的链接是

/tutorials/?p=3 

我想它去:

/wiki/sorry-this-tutorial-no-longer-exists 

我已尝试:

Redirect /tutorials/?p=3 http://domain.com/wiki/sorry-this-tutorial-no-longer-exists 

我得到的最接近是

RedirectMatch 301 ^/tutorials/?(.*) http://domain.com/wiki/sorry-this-tutorial-no-longer-exists 

但是,这当然是坚持的......存在/?在结束P = 3不工作

与血腥的问号任何帮助吗? (我试过htaccess url rewrite with question mark,但它不会工作?)

回答

1

我相信这应该做你在找什么

RewriteEngine on 
RewriteCond %{REQUEST_URI} ^/tutorials/$ 
RewriteCond %{QUERY_STRING} ^p=3 
RewriteRule ^(.*)$ http://domain.com/wiki/sorry-this-tutorial-no-longer-exists? [R=302,L] 
+0

是的,这看起来更像是它。但是,这仍然给我一个http://domain.com/wiki/sorry-this-tutorial-no-longer-exists/?p=3结果。无论如何删除?p = 3 – tjh

+0

道歉我错过了?结束。我已经更新了答案 – Anigel

+1

只是一个细节,但使用'^ \ bp = 3 \ b',否则像'?cab = 300'这样的查询模式将得到匹配。 – TerryE