为子目录中的所有页面创建重定向

时间:2012-06-14 13:16:07

标签: asp.net url-rewriting isapi-rewrite

到目前为止,我一直在使用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.aspx重定向到www.example.com/category-2/products.aspx

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

如何使用RewriteRule进行此操作?

1 个答案:

答案 0 :(得分:2)

试试这个

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