php - htaccess-rewriting, but excluding sub-directory -
this question has answer here:
- .htaccess exclude directory rewrited 1 answer
i have general rewrite-rule in sites root looks this:
rewriteengine on rewritecond %{request_filename} !-f rewriterule ^([\w]+)/?([\w]+)? index.php?action=$1
which works fine rewriting urls "www.example.com/myaction" "www.example.com/index.php?action=myaction"
this must stay this, need exclude subdirectory ("/login") rewriting.
so tried:
rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_uri} !^/login/ rewriterule ^([\w]+)/?([\w]+)? index.php?action=$1
but still no luck. i've read several answers here on can't find flaw. ideas? thank you!
you've slash. .htaccess
doesn't use preceding slash unlike virtual host
. /login/
directory. you're matching not real file, potentially real directory. if instance '/css/' exists, you're rewriting index.php action on request.
rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_uri} !^login/ rewriterule ^([^/]+) index.php?action=$1
if it's still acting unexpectedly might need make sure you're not rewriting existing directories , try this:
rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_uri} !^login/ rewriterule ^([^/]+) index.php?action=$1
i noticed you're capturing first slash (possibly) posted example code since you're using ?
look-up, in previous layout's i'm showing code little shorter. capture whole uri use this:
rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_uri} !^login/ rewriterule ^(.*) index.php?action=$1
to capture second (and third) string can this:
rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_uri} !^login/ rewriterule ^([^/]+)/([^/]+)/([^/]+) index.php?action=$1&page=$2&response=$3
Comments
Post a Comment