Ignoring a specific sub-sub folder

I want to ignore a rule I have for a specific virtual sub-subfolder location (not a physical folder, handled via expressionengine).


RewriteRule ^(admin)($|/) - [L]
RewriteRule ^(.*/)?index\\.([a-zA-Z0-9]{3,4})$ /$1 [R=301,L]

So this redirects any /index.php page to its root folder location… so site.com/index.php –> site.com… in all locations except the /admin/ folder.

I need this same rule to apply for a subfolder /index.php/member/login (I cannot login because it is processed through an index.php page which is redirected by the above rule)

How would the new rule/condition be here?

I haven’t tested this, but when I get to work I’ll give it a try, but I think this may do it:

Change

RewriteRule ^(admin)($|/) - [L]

To

RewriteRule ^(admin|member/login)($|/) - [L]

Nope, didn’t work but figured out a workaround.

the login form on the index.php/member/login/ page is a POST to site.com/index.php - which redirects the page without actually logging in.

Here is the fix I made that works…


RewriteCond %{REQUEST_METHOD} !=POST
RewriteRule ^(admin)($|/) - [L]
RewriteCond %{REQUEST_METHOD} !=POST
RewriteRule ^(.*/)?index\\.([a-zA-Z0-9]{3,4})$ /$1 [R=301,L]

Thanks for the suggestion!

Oleg,

WHY are you using something like “($|/)” in your regex? You simply need admin in the RewriteRule’s regex as it will match everything starting with (“^”) admin. For that matter, you don’t need the parentheses around admin, either (you don’t need to create an Apache variable for “admin”).

Okay, if there is no POST data, the second RewriteRule set captures the path to index.{something} and redirects to path/ (yes, $1 captures the / in the optional regex before index.{something} … but NOT the / between the domain and DocumentRoot, i.e., $1 will be empty (so you will not get // in the redirection. To prevent looping on index.{whatever}, presumably, you have DirectoryIndex set to provide the default file in that directory.

Problem: If the DocumentRoot’s index.php file has been requested, it will loop to the DirectoryIndex which is generally an index.php or index.html. I hope you are using some other filename.

Regards

DK

We need to be careful that the pattern doesn’t match more than it’s supposed to. For exmaple:

/admin-blah-blah

If the pattern were just ^admin, then we would unintentionally match the above URL. We need to make sure that “admin” is followed by either a slash (indicating the end of the path segment) or the end of the string altogether.