Configuration . Htaccess File

By Sepeda �� Selasa, 13 September 2011 2 comments

Apache web server has some configuration options that are available for server admins. In some hosting environments that are shared, you do not have access to the main Apache configuration so you're stuck using the default configuration. But you can override some default settings to create / modify a file named. Htaccess

. Htaccess file is a simple ASCII text file located in the www directory or subdirectory on www folder. You can create or edit a file in any text editor (Notepad) and then upload it to the directory you want to change the setting. Make sure that the file is uploaded in ASCII format instead of BINARY, and make sure the file permissions for the file are set to 644 (rw-r-r-). This allows the server to access the file, but prevents the user to access the file from their browser

Perintah2 inside. Htaccess file affect the directory it is located and all subdirectories. When you place. Htaccess file in www directory, then it will affect all of your website.

Almost all commands. Htaccess is designed to be placed in one line. If your text editor to auto-wrap (cut line), then you should disable the functionality. Note also that the command. Htaccess is case-sensitive

Please note that we do not technically support overriding the default setting. The information here may be working or not.

Some things you can do with. Htaccess include:

Customize Error Messages

If you want to change the server's error pages, you can use. Htaccess to define your own messages. This capability is discussed in the Custom Error Message of the manual. Examples of this syntax is:

ErrorDocument 500 / error.html

Override SSI Settings

By default, only pages with the extension. Shtml extension will parse server-side includes SSI on the server. You can change it in the file. Htaccess

If you want to change the configuration so that SSI will work with HTML documents, you can create file.htaccess and upload it to the main direkroti www. Add the following lines to the file

AddType text / html. Html
AddHandler server-parsed. Html

If you want both. Html and. Htm to run SSI, create a file. Htaccess with the following additional lines

AddType text / html. Html
AddHandler server-parsed. Html
AddHandler server-parsed. Htm

Change Your Default Home Page

That the user can access your site with just a domain name only (http://www.site.net) without having to write the file name explicitly (http:www.site.net/file.html), you must have an index file in the directory www. The file name is acceptable, among others, index.html, index.htm, index.cgi, index.php, etc.. Make sure that the file named index .*

There are levels in naming them. If you have index.cgi named index.html in your directory, the server will display index.cgi since. Cgi has a level higher than that. Html

With. Htaccess, you can define additional index file or change the order of precedence. To define hoeronymous.html as an index page, add the following line to the file. Htaccess

DirectoryIndex hieronymous.html

This will cause the server to look for a file named hieronymous.html. If it finds that the server will display it. But if not, then the server will display an error 404 Missing Page

To change the order of levels, enter a DirectoryIndex command with the names of files in one line. The order determines the order of writing file2 levels, for example:

Hieronymous.html DirectoryIndex index.html index.cgi index.php

Enable Directory Browsing

For security reasons, we have omitted the default settings that allow directory indexing. This is the option which allows the contents of the directory to be displayed in the browser when the directory does not contain an index page

For example, if you make an http call to a dir like http://yourdomain.com/images/, then the browser will display a list of images in that directory

If you require this option on a particular directory, you can activate it by adding the following line to the file. Htaccess

Options + Indexes

Block Users from Accessing Your Web Site

If you want to block access to some individuals, and you know the IP / domain name that is used, add the following line:
order deny, allow
deny from 123 456 789 000
deny from 456.78.90.
deny from. aol.com
allow from all
In the example above, the user's IP number 123.456.789.000 would be blocked. All the users of 456.78.90.000 to 456.78.90.999 would be blocked. And all users connecting from AOL.com will be blocked. If they try to access your site, it will show a 403 Forbidden error ("You do not have permission to access this site")

Redirect Visitors to a New Page or Directory

Suppose you re-create the entire website, to rename pages & directories. So visitors to the old page will get an error 404 File Not Found. These problems can be solved by doing a redirect from old pages to new pages. For example if you are old pages and new pages are oldpage.html newpage.html then the command is:
Redirect permanent / oldpage.html http://www.mydomain.com/newpage.html

If you rename the directory, the command is:

Redirect permanent / olddirectory http://www.mydomain.com/newdirectory/

Note that the old directory name is written with relative paths, while a new one written with absolute URL

Prevent Hot Linking and Bandwidth Leeching

To prevent others from linking directly to your image directory from their website, use:

RewriteEngine on
RewriteCond% {HTTP_REFERER} ^ $
RewriteCond% {HTTP_REFERER} ^ http:// (www.)? Mydomain.com / .* $ [NC]
RewriteRule. (Gif | jpg) $ - [F]

This will create a directory of images can only be accessed when the user is accessing www.mydomain.com

If you feel annoyed, you can create an alternative image if your image directory in-links. For example nosteal.gif image that reads: "stealing is Bad ... visit http://mydomain.com to see the real picture That belongs here." Then use the command:

RewriteEngine on
RewriteCond% {HTTP_REFERER} ^ $
RewriteCond% {HTTP_REFERER} ^ http:// (www.)? Mydomain.com / .* $ [NC]
RewriteRule. (Gif | jpg) $ http://www.mydomain.com/dontsteal.gif [R, L]

Prevent viewing of. Htaccess or other files

To prevent user access. Htaccess file, type the command:
order allow, deny
deny from all
If you want to prevent access other files, rename the. Htaccess file with another file name

Hopefully Helpful.

Sharing is sexy

Related posts

2 komentar for this post

  1. Hello Max i hope that you are Fine
    first congratulation about the engagement
    2nd the new version of the site is amazing really nice work here dont forget to invite me on your wedding :D

Leave a reply