开发者

RewriteCond match for certain parameter values, part 2

开发者 https://www.devze.com 2022-12-20 07:21 出处:网络
Before I begin, let me just say that I know my question is almost identica开发者_StackOverflow中文版l to this one.

Before I begin, let me just say that I know my question is almost identica开发者_StackOverflow中文版l to this one.

The difference is that, while I am trying to use a RewriteCond to identify a specific parameter in the query and redirect appropriately, I do not want the query string appended to the resulting URL.

Here's what I'm trying to do in my .htaccess file:

RewriteCond %{QUERY_STRING} d=i1013
RewriteRule subpages/view.php http://www.newdomain.com/

Except when I go to www.example.com/subpages/view.php?d=i1013, it redirects to www.newdomain.com/?d=i1013 and I want it to redirect to just www.newdomain.com

What am I missing here? I thought that the query string would be appended if I typed www.bing.com/$1, but I'm not, I'm leaving it off. Thanks for your ideas!


Use "http://www.newdomain.com/?" without the qsappend flag (which is the default). The empty query string replaces the original.

RewriteRule subpages/view.php http://www.newdomain.com/?

(And ServerFault seems a better place to ask this question, but don't do anything yourself at this point, it should soon enough be migrated there.)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号