I want to rewrite domain.com/pagename
to /index.php?page=$pagename
with this simple rule:
RewriteRule ^(.*)$ index.php?page=$1 [L]
But paradoxically I always get index.php
for $1
and not pagename
, why is that?
I want to rewrite domain.com/pagename
to /index.php?page=$pagename
with this simple rule:
RewriteRule ^(.*)$ index.php?page=$1 [L]
But paradoxically I always get index.php
for $1
and not pagename
, why is that?
2
Answers
Try this
http://example.com/pagename => http://example.com/index.php?page=$pagename
You have an infinite redirect loop, that’s why you get an unexpected result (weird you don’t get an Internal Server Error, by the way…)
Here is a rule for what you want
It checks if the url is not a physical folder/file before rewriting it internally. This rule is valid for one-level url only (eg.
http://example.com/placeholder
and nothttp://example.com/placeholder/somethingelse
)