帮助htaccess isapi重写

时间:2011-05-03 17:23:23

标签: .htaccess mod-rewrite redirect isapi-rewrite

RewriteRule ^olddomain.php?cat=39$ http://www.newdomain.com/firstdir/seconddir/? [R=301,NC]
RewriteRule ^olddomain.php\?cat\=39$ http://www.newdomain.com/firstdir/seconddir/? [R=301,NC] 
RewriteRule ^olddomain.php?cat\=39$ http://www.newdomain.com/firstdir/seconddir/? [R=301,NC]
RewriteRule ^olddomain.php\?cat=39$ http://www.newdomain.com/firstdir/seconddir/? [R=301,NC]

为什么他们工作?我认为这个问题与第一个问号,第一个等号或数字'39'有关...哈哈

1 个答案:

答案 0 :(得分:1)

记住RewriteRule仅匹配您的URI,它永远不会匹配主机名或查询字符串。以下是您正在尝试做的事情的正确方法:

Options +FollowSymlinks -MultiViews
RewriteEngine on

RewriteCond %{QUERY_STRING} ^cat=(.*)$
RewriteRule ^olddomain\.php$ http://www.newdomain.com/firstdir/seconddir/? [L,R=301,NC,NE]