rewrite with additional parameters

Nov 4, 2008 at 9:59 AM
Sorry in advance if there is a simple answer to this!

Im working on a site that currently rewrites most pages e.g becomes

We have since had a request to allow all pages to be tagged with additional items. Currently on the site this would return a 404 message,

so i need to be able to call and on all of the pages, without causing a loop. Is this possible?

the current rewrites are like
RewriteRule ^/register/?$               /account/register.asp [L]

below is the log when calling a page.

Tue Nov 04 10:05:12 2008 - ReplaceServerVariables: VariableName='HTTP_HOST' Value='www.example.local'
Tue Nov 04 10:05:12 2008 - ReplaceServerVariables: InputString='%{HTTP_HOST}' out='www.example.local'
Tue Nov 04 10:05:12 2008 - GenerateReplacementString: src='/register?id=123456','(null)' ReplacePattern='www.example.local' vec=[[  [  0, 26, 0, 26] [] ] counts=2,0
Tue Nov 04 10:05:12 2008 - EvaluateCondition: checking 'www.example.local' against pattern '^example.local'
Tue Nov 04 10:05:12 2008 - Cond : -1 (No match)
Tue Nov 04 10:05:12 2008 - Cond : Child is NULL
Tue Nov 04 10:05:12 2008 - EvaluateConditionList: FALSE, Rule does not apply

Nov 4, 2008 at 5:32 PM
There is a simple answer: add another rule.
You have a rule that handles /register amd /register/  .

Now you need one that handles register?id=123456  .  So the two rules would be: 

RewriteRule ^/register/?$                       /account/register.asp [L]

RewriteRule ^/register\?id=([0-9]+)$            /account/register.asp?id=$1  [L]

Nov 5, 2008 at 8:00 AM
Thanks for your post, i already have it working for individual URLs however i need it to work across the whole site so i was looking at a way of doing this with one rewrite, i am reluctant to do one for each page as there is quite a lot. Also the tag won't always be a numbers, it may be a guid.

Nov 7, 2008 at 7:17 PM
Well you'll need to define patterns that work more generally then.

I don't know what the other cases are, so I cannot make a direct suggestion.
If it might be a guid, then you can use

The testdriver.exe can help you try out different regular expressions.
Nov 11, 2008 at 2:05 PM
Any plan to implement Apache supported rewrite modifier QSA, which does exactly what Jameso1 needs - leaves the query string intact?
Nov 11, 2008 at 4:57 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.