Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apache RewriteRule: matching beyond "?"

Status
Not open for further replies.
Jul 11, 2002
878
CA
I am a complete newb to Apache and I am trying to use mod_rewrite to redirect requests to different servers depending on the incoming URL.

Basically I need to refer info requests for specific suppliers' products to their sites. This works fine where the match expression is in the basic url, for example:

RewriteRule SupplierA\.Product suppliera.com/Product.html [L]

works just fine when the incoming request is mydomain.com/SupplierA.Product.html

However, when the match expression is in a parameter, for example if the request is for a search:
mydomain.com/?Search=SupplierA.Product
then the match does not seem to work no matter what I do, unless I remove the ?

Two questions:
1. Is there any way around this - i.e. to match against the entire request string including $ and beyond. Is mod_rewrite inappropriate here? How else can it be done?
2. Is there a limit to the number of RewriteRules that can be in effect?

Any guidance would be appreciated.
Jock
 
OK, found the answer:

Use RewriteCond before RewriteRule, wherein you can match against %{QUERY_STRING}, which contains everything after the ?. So you do the query matching in the RewriteCond statements(s) preceding the RewriteRule, which is where you match the URL.

Jock
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top