【问题标题】:Help with htaccess redirect rewrite rule帮助 htaccess 重定向重写规则
【发布时间】:2009-07-21 15:53:01
【问题描述】:
我想使用 Helicon ISAPI Rewrite 将旧 URL 重定向到新 URL,但只能在名为 colors 的虚拟目录中:
http://www.mydomain.com/colors/default.aspx?id=blue
需要重定向到
http://www.newdomain.org/colors/default.aspx?id=blue
我是新手,找不到合适的例子,所以任何帮助都将不胜感激。
【问题讨论】:
标签:
.htaccess
url-rewriting
mod-rewrite
【解决方案1】:
Helicon ISAPI Rewrite 似乎共享 mod_rewrite 的语法,所以:
RewriteCond %{HTTP_HOST} www\.mydomain\.com
RewriteCond %{HTTP_URL} ^/colors
RewriteRule ^(.*)$ http://www.newdomain.org/$1 [R]
【解决方案2】:
这是另一种可能性:
RewriteBase /
RewriteCond %{HTTP_HOST} ^(?:www\.)?mydomain\.com$ [NC]
RewriteRule ^(colors/.*)$ http://www.newdomain.org/$1 [NC,R=301,L]