At jfoobar labs you will find "stuff" that is either cool, useful or for learning purposes. We hope to create a pretty nice selection over time. Remember, we need it to be fun.
When you are running a CMS, or for example a Blog you might also have SEO url's enabled through .htaccess rewrites. A common problem with these rewrites can be that you are no longer able to install a second application in a subfolder since those foldernames are included in the rewrites and can cause 404 errors.
To prevent the 404 errors, there is a single line which you can add to exclude such a foldername from being rewritten. Below a default .htaccess file for Wordpress:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
The line to add to this, to exclude a folder from being rewritten is:
RewriteCond %{REQUEST_URI} !^/(foldername|foldername/.*)$
Simply replace "foldername" with your own subfolder that needs to be excluded from the rewrite. So the complete .htaccess content would become:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/(foldername|foldername/.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Thank you much appreciated!
Thank you, i can now execute my cgi scripts without trouble.
I can't execute this code in my htaccess. Can i use this code with lighttpd?
Thanks for this. It helped immensely. To exclude multiple folders, the condition can be modified a little:
RewriteCond %{REQUEST_URI} !^/(folder1|folder2|folder3).*$
Thank you very much for this helpful snippet! This also worked for phpfox, just remember to add it twice to each set of rewrite commands.
Thank you again!!
Hi, I was wondering if you would know how to exclude a folder within a folder?
So not just example.com/folder1, but example.com/folder1/folder2/folder3
Thanks.
Copyright © 2008 jfoobar - All Rights Reserved - Joomla! is a registered trademark of Open Source Matters, Inc - Disclaimer
# 1 - Posted by: chali on 2009-03-27 07:50:39
Thanks you :)
You saved my day.