Reputation: 3463
I have a CMS installed at the root of my domain with the following htaccess:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
This takes care of friendly urls to redirect everything to index.php. My problem is that I have a sub-folder which has another cms. I need the requests to the sub-folder be redirected to the proper folder instead index.php.
I tried the following but it doesn't seem to work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(sub-folder)
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
Can anyone help?
Thanks
Upvotes: 12
Views: 13435
Reputation: 30087
You should verify properly if request uri match the sub folder
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !/subfolder
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
In any case, the first two rewritecond means: if request file name is not a file or a directory. Which means that if the file you are referencing is into the sub folder and the sub folder is into your docroot, you don't need to do anything.
If still won't work, enabling the log could help you:
RewriteLog "/web/logs/mywebsite.rewrite.log"
RewriteLogLevel 9
RewriteEngine On
avoid this log in production
Using a high value for Level will slow down your Apache server dramatically! Use the rewriting logfile at a Level greater than 2 only for debugging!
Upvotes: 17