.htaccess tutorial

htaccess Elite


Does .htaccess go in root or htdocs?

Anything not fitting into other categories

Does .htaccess go in root or htdocs?

New postby produke » 02 Oct 2006 02:13

I currently have one .htaccess file associated with my simple site and it's located in the root directory, i.e., listed under the cgi-bin and htdocs entries in 'file explorer' as (shaded) .htaccess.

Is that where it's suppose to be, or is it suppose to be inside the htdocs folder?

All the .htaccess file does at this time is 'hotlink' protection.

Thanks
User avatar
produke
 
Posts: 242
Joined: 25 Sep 2006 04:48

New postby produke » 02 Oct 2006 02:15

Actually, it depends what is in your htaccess file.

In my root directory, the .htaccess is

Code: Select all
AddHandler application/x-httpd-php .php .htm
Options -Indexes -ExecCGI -Includes -FollowSymLinks
DirectoryIndex index.htm index.html index.php


This specifies that my /public_html/ and /cgi-bin/ and whatever other dirs I have in root, be subject to those rules.

Then in my /public_html/.htaccess file I have the following
Code: Select all
ErrorDocument 404 /inc/e/error.htm
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} !powweb\.com$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule ^scripts/(.*)\.sll$ /cgi-bin/$1.php [T=application/x-httpd-php]



Note, not everything works from the root .htaccess.. and you should also realize that it is a bit more inefficient to use a htaccess file in your root dir.
User avatar
produke
 
Posts: 242
Joined: 25 Sep 2006 04:48


Return to Main