December 18, 2009

htaccess uses

CHMOD the htaccess file to 644 or (RW-R--R--)

htaccess files must be uploaded as ASCII mode, not BINARY

htaccess files affect the directory they are placed in and all sub-directories,

placing a new htaccess file within the directory you don't want affected with certain changes,
AccessFileName .config

The use of .htaccess files can be disabled completely by setting the AllowOverride directive to "none"
AllowOverride None [Options, FileInfo, AuthConfig, Limit]





================================================

Custom Error Pages

You can use custom error pages for any error as long as you know its number (like 404 for page not found) by adding the following to your .htaccess file:

ErrorDocument errornumber /file.html

For example if I had the file notfound.html in the root direct
ory of my site and I wanted to use it for a 404 error I would use:

ErrorDocument 404 /notfound.html

If the file is not in the root directory of your site, you just need to put the path to it:

ErrorDocument 500 /errorpages/500.html

These are some of the most common errors:

401 - Authorization Required
400 - Bad request
403 - Forbidden
500 - Internal Server Error
404 - Wrong page

=============================================

front page server extensions

=============================================

to stop the directory list from being shown:
Options -Indexes

you must have "AllowOverride Options" in effect to permit the use of the "Options" directive in .htaccess files.

you may wish to use a .htaccess file to permit the execution of CGI programs in a particular directory. This may be implemented with the following configuration:
Options +ExecCGI

=============================================

You can block an IP address by using:

deny from 000.000.000.000

allow from 000.000.000.000

deny everyone from accessing a directory, you can use: deny from all

==============================================

Alternative Index Files

DirectoryIndex index.php index.php3 messagebrd.pl index.html index.htm

==============================================

The following can be done to redirect a specific file:

Redirect /location/from/root/file.ext http://www.othersite.com/new/file/location.xyz

==============================================

.htaccess files can override the sections for the corresponding directory, but will be overriden by other types of configuration sections from the main configuration files. This fact can be used to enforce certain configurations, even in the presence of a liberal AllowOverride setting. For example, to prevent script execution while allowing anything else to be set in .htaccess you can use:


Allowoverride All



Options +IncludesNoExec -ExecCGI


==============================================

Another common use of .htaccess files is to enable Server Side Includes for a particular directory. This may be done with the following configuration directives, placed in a .htaccess file in the desired directory:

Options +Includes
AddType text/html shtml
AddHandler server-parsed shtml

Note that AllowOverride Options and AllowOverride FileInfo must both be in effect for these directives to have any effect.

==============================================

Finally, you may wish to use a .htaccess file to permit the execution of CGI programs in a particular directory. This may be implemented with the following configuration:

Options +ExecCGI
AddHandler cgi-script cgi pl

==============================================

To stop people from viewing the .htacess file in your site, include this line in the file:


order allow,deny
deny from all


==============================================

To stop hotlinl=king from other domains except the ones allowed below

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://bernhard.pro.br/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://bernhard.pro.br$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.bernhard.pro.br/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.bernhard.pro.br$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]

==============================================

No comments:

Post a Comment