Where to place .htaccess

Where to place .htaccess

Posted by: ItsMeDan
Posted on: 2006-07-01 06:50:00

I host several domains on my DH account. As you guys know each domain points to it's own folder.

For the time being all I want to do is redirect the 404 page back to the site index.html

I'm assuming I would place the file in the websites directory. Is it possible to place it in my FTP root all the redirects would be to /index.html anyhow.

2 more questions:

Should I place an htaccess in each subdomain folder?

What should the file permissions be on the actual .htaccess file?

Thanks in advance,
Dan

Re: Where to place .htaccess

Posted by: listenlight
Posted on: 2006-07-01 08:32:00

I'm not sure about multiple domains, but yesterday I set up an .htaccess for a custom 404 page, which is working. I put the .ht file in the same (root) directory as index.php. It is supposed to be fetched for every page request in my domain. Be sure to keep it hidden:

<Files .htaccess>
order allow, deny
deny from all
</Files>

double check that :)

hope I helped.


{update: yes, you will need an .htaccess file for each subdomain... see http://listenlight.net/nopage and then http://listenlight.net/thegrove/nopage to be sure }

{update: the file permission listed above will only deny access to the .htaccess file itself, you will need to use multiple entries or regular expressions to deny access to various other files, or simply prohibiting directory listing "Options -Indexes" for a lightweight security measure.. google ".htaccess" for better howto's }

Edited by listenlight on 07/01/06 08:51 AM (server time).

Re: Where to place .htaccess

Posted by: guice
Posted on: 2006-07-01 11:22:00

By default, .htaccess access has been stricken within the Apache config, so the above is not needed.

You need a .htaccess file within each document_root. That means, within the root of every domain.

File permissions, just normal. 640 or 644. Doesn't matter. 640 will also prevent others on the server from viewing your file through the command line.

Best way to redirect for 404 is to use:
ErrorDocument 404 http://www.domain.com/

This will redirect all 404 to the above URL. Just using /index.html will NOT redirect, but just put up "index.html" in place of the file not found.

Tags: index htmlhtaccess filedomain pointssubdomainredirectassumingdomainsftpanyhow