.htaccess single folder


#1

Hello Dreamhosters,
I have .htaccess working in the root directory of my site.
But I want a separate set of error pages for one particular folder of that site.
So I put a .htaccess file in that folder.
However, the file is being ignored.
How can I have a separate set of error pages for that one particular folder?
Thanks!
Harvey


#2

I have a separate .htaccess file in many folders because I want to change default pages (-DirectoryIndex ) for that directory, so I believe that you can change the path to the error files. I do this as well because in some sections of my site I want a modified 404 or 403 file.

I have included a sample below (most of which I found in the DH KB after they changed PHP –> PHP CGI). The change in index is kind of a hack but it does what I want.

.htaccess

IndexIgnore *.gif *.jpg *.psd *.png *.JPG *.GIF *.html *.php
DirectoryIndex includes_403.php

ErrorDocument 404 /errors/404.php
RewriteEngine on
Rewritecond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule .php$ /errors/404.php

ErrorDocument 401 /errors/401.php
RewriteEngine on
Rewritecond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule .php$ /errors/401.php

ErrorDocument 403 /errors/403.php
RewriteEngine on
Rewritecond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule .php$ /errors/403.php

–Simon

http://www.simonmetz.com


#3

Hi, thanks for the reply.

I’m trying to keep things really simple. I have a folder that has a few regular pages, an error page, and an .htaccess file. The .hatccess file simply has:
ErrorDocument 400 /folder/error.html
ErrorDocument 401 /folder/error.html
ErrorDocument 403 /folder/error.html
ErrorDocument 404 /folder/error.html
ErrorDocument 500 /folder/error.html

There’s also a .htaccess file at the root pretty much like this:
ErrorDocument 400 /error.html
ErrorDocument 401 /error.html
ErrorDocument 403 /error.html
ErrorDocument 404 /error.html
ErrorDocument 500 /error.html

The .htaccess file in the folder is being ignored and the one at the root is being followed.

Any idea why? Thanks!


#4

Ok, for anyone interested, I figured it out.
My .htaccess files were fine.
Problem was that when I was ftp’ing the new file up, it was not overwriting the old file, even though it seemed to be.
So my changes were never being implemented.
I had to delete the old .htaccess file first, and then upload the new one.
Works fine now.


#5

I found that certain programs like MS Word would lock the file, when ftping when the program is running. This makes it difficult when testing out theories. As it is required to shut down the program, upload, restart program, etc. But programs, like wordpad and notepad do not lock files.
Silk


#6

Hi, thanks for the post. But the issue was simply whether or not Dreamhost allowed an .htaccess file to be overwritten by an updated version of the .htaccess file. It’s simply a permissioning type thing that Dreamhost controls. They acknowledged this and are checking into whether the process (or documentation) needs to be changed (if they can duplicate the issue).


#7

Ahh, got cha.
Silk