By ventophile on
I have installed Drupal into my webspace, and there are other directories of files in my space that I still want to be able to access, which are not related to Drupal (eg. www.mysite.com/other).
However after Drupal is installed, if I try to access www.mysite.com/other I get a Drupal page, saying “Page not found”.
How do I allow web access to the other non-Drupal directories in my web space once again? (One of my non-Drupal directories is Gallery – www.mysite.com/gallery - and that works fine, but none of the others can be accessed any more…)
Many thanks!
Phil
Comments
Try editing your .htaccess to not rewrite your other directories
How can I stop drupal from taking over the rest of my site ?
.dan.
.dan. is the New Zealand Drupal Developer working on Government Web Standards
Thanks for that - I think
Thanks for that - I think that's where the solution should lie, but I'm still not clear about what I have to do. I tried adding a line like this:
RewriteCond %{REQUEST_FILENAME} !^mydirectory
in the .htaccess file, but I still couldn't access www.mysite.com/mydirectory
Can you give me any more clues? It seems odd that I can access the /gallery directory, but none of the other non-Drupal directories, even though there's no mention of the word "gallery" in the .htaccess file.
My Drupal installation is in public_html (ie. not in a subdirectory). And I'm a complete novice with .htaccess!
Thanks... Phil
2 things
Your RewriteCond needs to be directly above the rewrite rule, it's an if(and)-then structure.
Other than that, it sure should work.
Do you now get a server 404 or a Drupal page not found?
Rewrite kicks in only if no real file is found in the first place. So if there is a /gallery/index.php, then requesting /gallery/index.php should bypass it. (I think, there may be more to it. mod_rewrite is a beast)
If you still have problems, there might be something else subtle or obvious that you're overlooking.
Note that .htaccess has also changed your default document to index.php - so if your new directory is trying to serve up index.htm it will be ignored ... unless you ASK for index.htm by name.
You can double up the options like so.
----
DirectoryIndex index.php index.htm
----
.dan.
http://www.coders.co.nz/
.dan. is the New Zealand Drupal Developer working on Government Web Standards
In addition to dman's good
In addition to dman's good post.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
In plain English: If the REQUEST_FILENAME variable does not exist (not an existing File and not an existing directory) then apply the rule:
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
So if it's an existing file or folder the rule will not apply and bypass the drupal control (index.php).
If loading a subfolder include the file to bypass DirectoryIndex.
Like: www.yoursite/aFolder/mypage.htm.
If that solves your problem update your DirectoryIndex to include your new default "homepage" type (i.e index.html mypage.htm...etc..).
This article is about another issue (IIS cleanURLs) but explain what those 3 instructions and options ([L,QSA]) are about:
http://www.sitebuddy.com/Drupal/IIS/CleanURLs
Make sure your Apache installation is indeed reading your .htaccess.
If Drupal CleanURLs works, most likely your htaccess is being loaded.
Hope this helps,
Christophe D
Thanks - one more question
Adding index.htm to DirectoryIndex fixed it - clearly Gallery has an index.php but none of my other subfolders do :) Many thanks to you both.
Another quick question - some of my subfolders just contain files that I upload now and then to use "on the road", without there being an index.htm file to reference them. Before I installed Drupal, I would just browse to www.mysite.com/temp and Apache would automatically generate a directory listing for the files within, but now it doesn't (I get the "Page Not Found" error within a Drupal page). Is there something I can change in the .htaccess file to put that back the way it was, so non-Drupal folders get an automatic directory listing when I browse them?
Thanks :)
Phil
Please have a look at Apache httpd.conf
It is the single best commented configuration file in the history of software.
It explains and gives examples of all sorts of common setups.
The keyword you are looking for is "Options Indexes", and yes, Drupal turned those of on its own directory on purpose - for security.
.dan.
http://www.coders.co.nz/
.dan. is the New Zealand Drupal Developer working on Government Web Standards
My Solution to accessing non-drupal password protected folders
I'm running drupal 5 on a shared server running apache 1.3
I wanted to have a simple "friends" directory/folder to put files etc. for my friends to download. (I find this easier than sending large files by email)
After much searching I found the following solutions:
To access the files in the directory:
add a .htaccess file to that directory containing
Options AllTo make simple .htaccess password protection work:
e.g. for something like this
edit the drupal-web-root/.htaccess file (eg. public_html/.htaccess) and add a Rewrite Condition
i.e. Find...
and add
RewriteCond %{THE_REQUEST} !/path-to-directory/.*before the ReriteRuleto get...
path-to-directory is the path after the hostname. ie. to grant access to
www.yourdomain.com/ftpyou would putRewriteCond %{THE_REQUEST} !/ftp/.*See http://www.thesitewizard.com/apache/access-non-drupal-folders.shtml for an explanation of why
Options Alldoesn't work for password protected directories/folders.Having just finished writing this little HowTo comment I now find that I understand thesitewizard's instructions (which didn't work when I firest tried them). They key is in understanding how apache handles paths. The path to the 401.html file specified in "ErrorDocument 401 /401.html" is www.yourdomain.com/401.html
I preferred to put mine in the directory/folder that I wanted to give access to which meant it had to be "ErrorDocument 401 /ftp/401.html"
Well there we are. Now there is one more explanation of how to do this and hopefully this post will make it just a little easier for someone to find the answer they need.
Jesse
Wind Wanderer Storytelling
Help with a multi-site .htaccess
Thanks so much for these instructions, and for the link to thesitewizard. However, my Drupal project is a multi-site/multi-domain project. (Full disclosure: I am not the original developer.) The issue I am running into is that the site is automatically redirecting the URL for my password-protected directory to the user login. My .htaccess looks a little bit different than yours:
I modified it this way:
That allowed me to access the directory, but then it threw that directory into a 500 Internal Server error -- .htaccess related, I'm sure.
I also tried this modification, but no change. I cannot access the directory and am still redirected to the user login.
Ideas??
Error 500 and newer d7 version
I'm in the same situation as this. but with a normal D7 install 7.35
It does not work as described.
Works in D7
I can confirm that this works for with Drupal 7.21, four years later. This was a surprisingly difficult issue to find a working answer for on the web, so thanks tamlin.
Adding
RewriteCond %{THE_REQUEST} !/directory-name/.*right before
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]in .htaccess at the root level did the trick and provided anonymous access to files uploaded via FTP to the "directory-name" directory in the drupal root directory.
this solution is still good!
Hey Jesse, I just made this work for Drupal ver 7.37. I have a non-drupal directory that needs password protection via cPanel (which makes its own .htaccess for the directory being protected). Adding the following line to my Drupal's root .htaccess allows the other to work properly:
# Pass all requests not referring directly to files in the filesystem to
# index.php. Clean URLs are handled in drupal_environment_initialize().
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteCond %{THE_REQUEST} !/path-to-directory/.*
RewriteRule ^ index.php [L]
Thanks,
Nathan Clark
www.clarkwebworks.com
Non Drupal directory rewrite code for 7x .htaccess
Thank you Nathan for including the code many years after the OP - helpful!
No longer works with 7.53 - Any new ideas?
Hello,
I am new to Drupal, but was happy when I came across this post.
However, when we tried the suggestions presented, we were unable to get anything but 'page not found' returned from Drupal, even though Apache itself was returning a HTTP 401.
In trying older versions of Drupal (e.g. v7.38), we did not even have to update the .htaccess file in order to be able to use HTTP Basic Auth against the site for directories outside of the docroot.
Now with v7.53, I have been unable to get HTTP Basic Auth to work for any directory, no matter what I have tried.
If anyone has any suggestions, I would greatly appreciate it.
Thanks!
Confirmed to work for Drupal
Confirmed to work for Drupal 7.56.
Thanks for the improved solution!
Can confirm works on Drupal 8.6.9
Can confirm works on Drupal 8.6.9
Thanks for the instructions:
Thanks for the instructions: it works in my Drupal application.