2012-06-14 44 views
0

到目前为止,我一直在使用ISAPI_REWRITE为ASP.NET网站上的单页设置重定向。这很好地工作(如下图所示):为子目录中的所有页面创建重定向

# Redirect 
RewriteCond %{HTTP:Host} ^(?:www\.)?example\.com$ 
RewriteRule ^/category-1/products\.aspx /category-2/products\.aspx [I, R=301] 

这将重定向到www.example.com/category-1/products.aspxwww.example.com/category-2/products.aspx

但是,现在我想重写它,以便对类别1内的页面的所有请求都重定向到类别2上的相同页面,即www.example.com/category-1/allpages.aspxwww.example.com/category-1/allpages.aspx

如何用RewriteRule解决这个问题?

回答

2

尝试用这种

# Redirect 
RewriteCond %{HTTP:Host} ^(?:www\.)?example\.com$ 
RewriteRule ^/category-1/(.*) /category-2/$1 [I, R=301] 
相关问题