Drupal is installed in my root directory and I have a subdirectory by the name of sandbox where I test new sites and the default .htaccess that comes with Drupal is causing problems. If I try to reference things relatively I get the Drupal 404 error page instead of the page that I'm wanting.

Could someone show me how to modify the .htaccess so that it will just avoid the sandbox subdirectory? Here's the current rules:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Thanks,
jeremy

Comments

cog.rusty’s picture

Take a look at these handbook pages:

http://drupal.org/node/167169 - What exactly you want to do
http://drupal.org/node/30334 - How to do it

Essentially the lines you mentioned say: "if it is not a real file, and if it is not a real directory, then let Drupal handle it"

However, if your subdirectory
(a) does not allow browsing files (because of the Options -Indexes line)
(b) does not contain an index.php file (as specified in the line DirectoryIndex index.php)
then for some reason it is not excluded.

Besides what is mentioned in the handbook page, if you want that subdirectory for running some specific non-Drupal applications which do have an index file, you could add to Drupal's .htaccess line:

DirectoryIndex index.php index.asp index.html index.htm (order matters if more than one index files exist)

or just add one of those in a new .htaccess file in the subdirectory. Then Drupal should leave it alone.

A radical solution is to change those .htaccess lines to:

RewriteCond %{REQUEST_FILENAME} !-U
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

That has been bulletproof for me but I don't have feedback from others, so don't take my word on it. With this method, it is between you and Apache. A missing index file will just give you an Apache "access denied".

jweiss’s picture

Thanks.

I had tried searching for it but I guess I wasn't using the right keywords. :(

But, the links to the articles gave me the info I needed to get it going.

Thank you.