apache - .htaccess rewrite php to php file -
i trying write rewrite rule. want simplify entered url use index. input url www.example.com/home.php
, rewritten www.example.com/index.php?r=page/home
.
i wrote .htaccess
file:
rewriteengine on rewriterule ^([^/]*)\.php$ /index.php?r=page/$1 [l]
this configuration unfortunately gives me error 500. can understand caused fact if enter index.php
instance, apache not know if must use index.php
file or use rewritten url index.php?r=page/index
.
is possible accomplish kind of rewriting rule apache? if so, how can fix error 500?
edit: please note rewriterule works fine if change extension .php
else such .html
, so: rewriterule ^([^/]*)\.html$ /index.php?r=page/$1 [l]
you have 2 possibilities.
first one
rewriteengine on rewriterule ^index\.php$ - [l] rewriterule ^([^/]+)\.php$ /index.php?r=page/$1 [l]
second one
rewriteengine on rewritecond %{the_request} \ /([^/]+)\.php rewriterule ^.*$ /index.php?r=page/$1 [l]
Comments
Post a Comment