我试着转发此网址,但其没有工作 - 这是我的代码:如何一个URL转发到另一个使用mod_rewrite规则
RewriteRule ^https://www.wsjwine.com/discovery_offer.aspx?promo=2227006$ https://www.wsjwine.com/discovery_offer_lp2.aspx?promo=2227006 [L]
我试着转发此网址,但其没有工作 - 这是我的代码:如何一个URL转发到另一个使用mod_rewrite规则
RewriteRule ^https://www.wsjwine.com/discovery_offer.aspx?promo=2227006$ https://www.wsjwine.com/discovery_offer_lp2.aspx?promo=2227006 [L]
With RewriteRule
directive您只能测试URL path。对于进一步的测试,您需要使用额外的RewriteCond
directives。
现在,如果你要重写的每个请求/discovery_offer.aspx到/discovery_offer_lp2.aspx不管查询的样子,你可以使用这个(例如,用于.htaccess文件的根目录):
RewriteRule ^discovery_offer\.aspx$ discovery_offer_lp2.aspx [L]
如果不指定替代查询,最初请求的查询将自动添加到新的一个。
如果你只是想重写特定的URL,试试这个:
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} =www.wsjwine.com
RewriteCond %{QUERY_STRING} =promo=2227006
RewriteRule ^discovery_offer\.aspx$ discovery_offer_lp2.aspx [L]
无法检测查询字符串这样。使用RewriteCond %{QUERY_STRING}
。
真棒,正是我一直在寻找! – jrutter 2010-01-22 16:14:22