+ Reply to Thread
Results 1 to 3 of 3

Thread: mod_rewrite

  1. #1
    Steven10172 is offline x10Hosting Member Steven10172 is an unknown quantity at this point
    Join Date
    Sep 2007
    Posts
    23

    mod_rewrite

    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/calcul...hp?page=bbcode, as the page=bbcode doesn't get sent.

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

    P.S. If you want to look at the error log go to http://pastebin.ca/1363785
    Last edited by Steven10172; 03-18-2009 at 07:03 AM.

  2. #2
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

    Re: mod_rewrite

    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.
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

  3. #3
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: mod_rewrite

    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 by misson; 03-22-2009 at 12:23 AM. Reason: clarifications

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers