I have written a redirect to change quiz.php?quiz=1 to /quiz/1 however PHP can no longer pickup the GET Variables, is there anything i’m missing? This is my htaccess file:
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^quiz/([^/]*)$ /quiz.php?quiz=/$1 [QSA,L]
2
Answers
You have error in RewriteRule ^quiz/([^/]*)$ /quiz.php?quiz=/$1 [QSA,L]
There should not be slash at redirect target, so correct is
RewriteRule ^quiz/([^/]*)$ /quiz.php?quiz=$1 [QSA,L]
I tried this on localhost and it is working properly. Try debugging via e.g. var_dump($_GET);
In this specific case, you probably need to disable content negociation and
AcceptPathInfo
features by adding the following lines to your .htaccess file:Content negociation can internally “rewrite” “quiz” into “quiz.php”. And
AcceptPathInfo
“quiz.php/a/b/c” to “quiz.php” with$_SERVER['PATH_INFO']
= ‘/a/bc/c’. They both happen before rewriting, bypassing your rule.