Forum Moderators: phranque
Here are the contents of my .htaccess file:
Options Indexes FollowSymLinks Includes ExecCGI
RewriteEngine on
RewriteBase /
RewriteRule ^(.*)\.html$ /includes/wrapper.php?p=$1.html
Currently, the above rule successfuly performs the following logical rewrite task:
Rewrites
/directory/path/file.html
to be
/includes/wrapper.php?p=directory/path/file.html
So in other words, any requests for .html files get parsed through a PHP script at /incudes/wrapper.php which receives a query string variable named "p" that holds the path to the originally requested .html file.
That works fine, but I would love to be able to also carry over any query string variables that were in the original request string as well.
So, in other words, if the user requested:
/directory/path/file.html?var1=value1&var2=value2
that would get rewritten (via mod_rewrite) into:
/includes/wrapper.php?p=directory/path/file.html&var1=value1&var2=value2
Here is my best (yet failed) attempt at creating a rewrite rule that accomplishes the above.
RewriteRule ^(.*)\.html[\?]?(.*)$ /includes/wrapper.php?p=$1.html&$2
Note: I know that the portion that reads[\?]?does not necessarily need the brackets, but this forum changes two question marks that are next to eachother into a single question mark. So I had to insert the brackets in the above example.
But unfortunately, this second rewrite rule seems to function identically to the first one. Any query string variables that were in the original request, do not seem to get "carried over" to the rewritten path.
Can any of you regex gurus out there tell me if I am doing something silly? Or is there some other special method that mod_rewrite makes available to allow for what I am trying to accomplish? I would think this is a fairly simple issue since I am merely looking to carry over verbatim anything to the right of a question mark in the original query string (excluding a question mark if it exists). I poured over the mod_rewrite documentation, but my wee mind couldn't make any connections. :)
Thanks for any assistance that anyone is able to provide. Sorry if this is mind-numbingly basic!