I'm quite experienced in PHP but I don't quite use
mod_rewrite (although I should). All I want to ask is if it's possible to pass many variables through a single rewrite rule.
For example, is it possible to rewrite this:
and also use the same rewrite rule for different values?
I know it can be done using Ajax, cookie, session, or POST variables, but I really want to use GET variables.
Apache returns sitemap.xml not /sitemap
Rails time stamps on images in CSS
PHP cannot find my php files if not under htdocs folder
Something like this would do it:.
mod_rewrite - splitting up arbitary number of terms?
However, you will lose your variables if you do that, as it's effectively the same thing as accessing localhost/mysupertest directly, with no query string data.
RewriteRule test.php\?(.*)$ mysupertest/
help needed with Lighttpd and Apache cofiguration with Django
If you want to keep the variables, perhaps in a REST-style url, you can use back-references to rewrite them.
Can apache's ProxyRemote be used to proxy HTTPS requests to mongrel for processing?
As John mentioned, a back-reference is simply a set of brackets, and whatever matches inside them becomes a variable in a numeric ordering scheme..
/usr/bin/env questions regarding shebang line pecularities
With the above rule, accessing
RewriteRule test.php\?id=(.*)&name=(.*)&var3=(.*) mysupertest/$1/$2/$3
test.php?id=567&name=test&var3=whateverwould be the same as accessing
How can I parse Apache's error log in PHP?
[QSA]option for mod_rewrite, which will append all the URL parameters from '
Take a look at this question for more details..
RewriteRule ^mysupertest/? test.php [QSA]
Anything you can match with your regex expression can be rewritten as any url.
Anytime you put part of your regex string inside of parenthesis ( ), it becomes a variable that can be used while rewriting.. You would want something like (I think):.
RewriteRule test.php\?id=[0-9]+&name=.+&var1=[0-9]+ mysupertest/.
From the documentation for RewriteRule:.
Note: Query String. If you wish to match against the hostname, port, or query string, use a RewriteCond with the