regex - mod_rewrite last match -
my htaccess located in localhost/me/.htaccess
, , want append after last / .php
e.g. localhost/me/test/index
rewrites localhost/me/test/index.php
so far rewriterule ^([a-za-z]+)$ $1.php [nc,l]
works localhost/me/index
, can't working first example there. why doesn't ^/([a-za-z]+)$ /$1.php [nc,l]
work, , how change work?
it doesn't work because you're matching on alpha letters , don't have /
in character class, uri me/test/index
. try this:
rewriteengine on rewriterule ^([a-za-z/]+)$ $1.php [nc,l,qsa]
also, since you're using [nc]
, need a-z
rather a-za-z
doesn't hurt anything.
Comments
Post a Comment