RewriteRule Help

I’m having a little trouble with a rewriterule. I haven’t had much experience with them and so help would be great. I want to change /index2.php?page=value&someVar=someVar to /page?someValue=someValue. My attempt is below.

DirectoryIndex index.php

suPHP_ConfigPath /home/gamejun/public_html/race

Options +FollowSymLinks -MultiViews

RewriteEngine on
RewriteRule ^([^/\\.]+)$ index2.php?page=$1
RewriteRule ^([^/\\.]+)\\?to=([^/\\.]+)$ index2.php\\?page=$1&to=$2 [L]

nlh,

First, it looks like you’re attempting to redirect FROM a usable (serveable) URL to something which is not. Nomenclature IS critical when dealing with the logic behind code.

Okay, it looks like you’ve “got the direction” correct with your code - just not dealing with the variables you have access to correctly.

Rather than go through (repeat) all the details of the FIRST sticky post and the mod_rewrite tutorial Article linked in my signature, let me refer you below with emphasis on the Apache variables {REQUEST_URI} (the ONLY variable that a RewriteRule can access in its regex) and the {QUERY_STRING} (which can only be accessed via a RewriteCond statement). That should be sufficient to let you know WHY your pair of RewriteRules failed to access anything past the ? (the OPTIONAL metacharacter in regex) in your URIs.

Come back with questions … if you still need to.

Regards,

DK