Reputation: 57
I am writing an .htaccess rule as
RewriteRule ^questions\/interview\/list\/(.+)$ questions\/interview\/list\/index.php?col1=$1
So, when I am calling url questions/interview/list/testme
it's redirecting to index.php
.
Issue is when i am printing $col1
its showing index.php instead of testme. What am I doing wrong ?
Upvotes: 1
Views: 81
Reputation: 143916
This is because the rewrite engine loops, try adding some conditions:
RewriteCond %{REQUEST_URI} !index\.php$
RewriteRule ^questions/interview/list/(.+)$ questions/interview/list/index.php?col1=$1 [L]
or even:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^questions/interview/list/(.+)$ questions/interview/list/index.php?col1=$1 [L]
When the rewrite engine loops, the (.+)
part of your regex ends up matching index.php
, and thus col1=
turns into index.php
.
Upvotes: 3