0

I'm trying to have htaccess do the following

redirect all request from site.com/ to subdir 'subdir' except if request uri starts with /mantisbt/

I used the following code from this answer (https://stackoverflow.com/a/5793784/1839903) and added a condition (line 4) but it is not respected.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?site.com$
RewriteCond %{REQUEST_URI} !^/subdir/
RewriteCond %{REQUEST_URI} !^/mantisbt/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /subdir/$1
RewriteCond %{HTTP_HOST} ^(www.)?site.com$
RewriteRule ^(/)?$ subdir/index.php [L]

I'd like to mention that in subdir/.htaccess, I have required htpasswd user, and when I go to site.com/mantisbt/whatever it asks me for a valid user/pass (not the standard mantisbt login, a browser directory protected access). If I remove all Rewrite rules and conditions, then site.com/mantisbt/whaterver is working as expected, but of course, site.com/? is not served by files in root/subdir.

I hope my question is clear, please request more info if necessary.

Thanks for your help,

Community
  • 1
  • 1
MatH
  • 137
  • 8
  • You may want to add a `[L]` to the end of your first rule, but it's working fine for me. – Jon Lin Mar 18 '14 at 19:26
  • Thanks Jon, I'll try that and get back with how it goes. – MatH Mar 21 '14 at 13:26
  • I still have the issue. I will be able to lift the password protected directory soon so I think I'll just abandon the idea of a fix. – MatH Mar 24 '14 at 19:10

0 Answers0