mod_rewrite

Steven10172

New Member
Messages
23
Reaction score
0
Points
0
I currently have:

Code:
RewriteEngine On
RewriteRule ^en(\w+)/(.+)$ /claimer/$2?world=en$1
RewriteCond %{QUERY_STRING} .+
RewriteRule ^en(\w+)/(.+).php$ /claimer/$2.php?page=%1&world=en$1 [L]

and it doesn't send the variable page.


An example url that doesn't work is: http://www.twclaimer.com/en10/calculator.php?page=bbcode, as the page=bbcode doesn't get sent.

I want the input of http://www.twclaimer.com/en10/calculator.php?page=bbcode and the output of http://www.twclaimer.com/claimer/calculator.php?page=bbcode&world=en10 but it only outputs http://www.twclaimer.com/claimer/calculator.php?world=en10

P.S. If you want to look at the error log go to http://pastebin.ca/1363785
 
Last edited:

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
250
Points
63
I'm having a hard time deciphering what you want the input and output uri to be. Maybe you could give an example of the input and output you want.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
I think I know what you're getting at. You look to have 2 misconceptions about the rewrite engine. Here's two facts to set you straight: patterns don't match against query strings (the documentation isn't very clear on this) and if you specify a query string in a substitution, it will replace the current query string (the documentation mentions this in the description of the QSA flag). Use the QSA flag on a rule will make the rewrite engine append to the query string rather than replacing it.

Also, your first RewriteRule would apply anytime the second would. As the first alters the URL, the second RewriteRule will never match.

And another thing: you don't have grouping operators (i.e. parenthesis) in your RewriteCond, so the "%1" in the following RewriteRule will be empty.

I thing this is what you're looking for:
Code:
RewriteEngine On
RewriteRule ^/?(en\w+)/(.+)$ /claimer/$2?world=$1 [QSA]

That should turn /en10/calculator.php?page=bbcode into /claimer/calculator.php?page=bbcode&world=en10
 
Last edited:
Top