I want to redirect all:
example.com/{anything}
to:
example.com/index.php?q={anything}
But when I try:
example.com/aaa?param=xxx
I only got 'aaa' in the 'q' parameter, and the '?param=xxx' is lost. why? and how to keep it?
my current rule is:
RewriteEngine on
RewriteRule ^(.*)$ index.php?a=$1 [QSA,L]
Did you test you actually do not get the param? For me, the param is not visible in the URL, but it it indeed passed.
I simply used this:
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ ip.php?q=$1 [QSA]
And tried this on top of ip.php:
<?php
if(isset($_GET['q'])) {
echo "PASSED: ".$_GET['q'];
}
?>
In this case, when I visit
mypage.com/SOMETHING
it seems it stays there, but $_GET param 'q' is set to SOMETHING. Without the above rewrite rules you will get 500 internal error usually.
Also check your server mod_rewrite rules etc. for certain specifics.