regex - Mod rewrite everything except specific subfolder -
i'm trying redirect except subfolders admin
, api
admin
, so:
/ - redirects /admin /some-url - redirects /admin /admin - doesn't redirect /admin/1 - doesn't redirect /api - doesn't redirect /api/v1/etc - doesn't redirect
but i've got far doesn't redirect correctly. here's mod_rewrite:
<ifmodule mod_rewrite.c> rewriteengine on rewritecond %{request_uri} !^/(admin|api) rewriterule ^ /admin [r,l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_uri} !=/favicon.ico rewriterule ^ ./index.php [l] </ifmodule>
you should use the_request
variable instead of request_uri
request_uri
changes value due last rule , in next iteration of mod_rewrite
rewrite condition in first rule returns true.
<ifmodule mod_rewrite.c> rewriteengine on rewritecond %{the_request} !/(admin|api) [nc] rewriterule ^ /admin [r,l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_uri} !=/favicon.ico rewriterule ^ ./index.php [l] </ifmodule>
Comments
Post a Comment