Apache RewriteCond with dynamic query string

Posted on 2008-11-06
Medium Priority
Last Modified: 2008-11-06
I have the following rewrite in Apache2.2:
RewriteCond %{QUERY_STRING} =Action=Load&Merchant_Id=1&Section_Id=123
RewriteRule ^/sectionpage.php$ /sale [R=301,NC,L]

The Rewrite works correctly if the query string is an exact match. So
 rewrites to

But I need to also rewrite for all URLs that contain the query string anywhere

This should be a pretty basic rewrite but I am not getting it to work.
Question by:KirkSamuels
1 Comment
LVL 27

Accepted Solution

caterham_www earned 2000 total points
ID: 22899425
But the order of the variables is the same?

Remove the '=' operator, which means that the string is a regular expression, which would match anything left or right to the string:

RewriteCond %{QUERY_STRING} Action=Load&Merchant_Id=1&Section_Id=123
RewriteRule ^/sectionpage.php$ /sale [R=301,NC,L]

Open in new window


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month14 days, 19 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question