htaccess - 不能为我的生活匹配这个URL

时间:2016-03-17 15:51:48

标签: regex .htaccess redirect match

http://www.matthewsvolvosite.com/for...p?f=11&t=17479

需要匹配和301重定向。我试过了

RedirectMatch 301 ^/for\.\.\.p?f=11&t=17479$ /forums/viewtopic.php?t=17479

RedirectMatch 301 ^/for(.*)f=11&t=17479 /forums/viewtopic.php?f=2&t=17479

都没有工作。我搜索并尝试了很多例子。我不知所措。

.htaccess文件匹配并重定向许多其他字符串。

RewriteBase /

正在运作。

1 个答案:

答案 0 :(得分:1)

您需要使用mod-rewrite

RewriteEngine on

RewriteCond %{QUERY_STRING} ^p=11&t=17479$
RewriteRule ^for\.\.\.p$ /forums/viewtopic.php?t=17479 [NC,L,R]

您的重定向无效的原因是您使用mod-alias来处理查询字符串。