Friday, July 8, 2011

Configuration File ".htaccess"

Apache web server has some configuration options that are available for server admins. In the space of a few shared hosting, you do not have access to the main Apache configuration, so you're stuck using the default configuration. But you could just replace some default settings to create / modify a file named .htaccess

.htaccess file is a simple ASCII text file that is located in the directory "www", or in a sub directory folder "www". 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, not BINARY. Make sure the file permissions for the file has been 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.

The commands in the file ". htaccess" affect the directory it is located and all subdirectories. When you put the file ". htaccess" in the directory "www", 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, we do not technically support overriding the default setting. The information here might not work. We suggest, first backup the original htaccess file.

Some things you can do with. "Htaccess", including:


1. 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

2. Override SSI Settings

By default, only pages with the extension ". shtml" that could run a "server-side", including the SSI on the server. You can turn it on. Htaccess file.

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 addition of the following lines

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

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 name of a file can be used include: 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, because. "Cgi" has a higher level than ". Html".

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

DirectoryIndex hieronymous.html

This will cause the server to look for a file named hieronymous.html. If the server find the file, then 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:

DirectoryIndex hieronymous.html index.cgi index.php index.html

3. 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 create 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



4. Block Users from Accessing Your Web Site

If you want to block access to some individuals, and you know the IP / domain name that he 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, a user with the IP 123 456 789 000 will 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")

5. Redirect Visitors to a New Page or Directory

Suppose you re-create the entire website, to rename pages & directories. Thus, 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 your old pages was "oldpage.html", and your new page is "newpage.html", so 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.

6. 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]



7. 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.

-------------------------------//---------------------------------------------------

Other Our Article :


Configuration File ".htaccess"
4/ 5
Oleh

Berlangganan via email

Suka dengan postingan di atas? Silakan berlangganan postingan terbaru langsung via email.