only for the Linux host, the WIN host cannot define the
.htaccess file (Hypertext Access file) is a very powerful configuration file for the Apache Web server, with a stack of parameters for this file To allow you to configure almost anything you want. The.Htaccess configuration file adheres to a culture of Unix - using a ASCII plain text file to configure your site's access policy.
this article includes 16 very useful tips. In addition, because.Htaccess is a fairly powerful configuration file, a slight grammatical error will cause a failure of your entire site, so when you modify or replace the original file, you must back up the old file so that you can recover when the problem occurs.
1. uses.Htaccess to create custom error pages. This is a very simple matter for Linux Apache. Using the following.Htaccess syntax, you can easily accomplish this function. (put.Htaccess in the root of your website)
[code]ErrorDocument 401 /error/401.php
ErrorDocument 403 /error/403.php
ErrorDocument 404 /error/404.php
ErrorDocument 500 /error/500.php[/code]
2. setup time zone / > > >
3. prevents IP list
sometimes you need to block access by way of IP address. Whether it is a IP address or a network segment, this is a very simple thing, as shown below:
[code]allow from all
deny from 145.186.14.122
deny from 124.15[/code]
4. transfers some old links to new links (301 redirects) - Search Engine Optimization SEO
[code]Redirect 301 /d/file.htmlhttp://www.htaccesselite.com/r/file.html[/code]
5. to set up e-mail for server administrators.
[code]ServerSignature EMail
SetEnv SERVER_ADMINdefault@domain.com[/code]
6. uses.Htaccess to access stolen chains. If a picture on your site is cited by a number of other N sites, it will probably lead to a decline in the performance of your server, using the following code to protect some of the hot links from being too much of a reference.
[code]Options FollowSymlinks
Protect Hotlinking
RewriteEngine On
RewriteCond%{HTTP_REFERER}! ^$
RewriteCond%{HTTP_REFERER}! Nc.#93; [/code]
7. prevents all User Agent requests from
[code]##.Htaccess Code. L.#91; NC, OR.#93;
SetEnvIfNoCase user-Agent ^MSFrontPage.#91; NC, OR.#93; Y
Allow from all
Deny from env=bad_bot
> >.Htaccess Code: END[/code]
9. open the file directly instead of downloading - usually, when we open the online file, we always appear a dialog box asking whether we are downloading or directly opening it, using the following settings will not be the problem, directly open.
[code]AddType application/octet-stream.Pdf
AddType application/octet-stream.Zip
AddType application/octet-stream.Mov[/code]
10. modify the file type - the following example can make any file become a server that is interpreted by the server. For example, myphp, CGI, Phtml and so on.
[code]ForceType application/x-httpd-php
SetHandler application/x-httpd-php[/code]
11. prevents access to.Htaccess file
[code]# secure htaccess. Access of a certain fileorder allow, deny
deny from all[/code]
13. prevents directory browsing. L[/code]
15. password authentication - you can create a file for authentication. The following is an example:
[code]# to protect a file
AuthType Basic
AuthName "Prompt"
> > >. >AuthUserFile /home/path/.htpasswd
AuthGroupFile /dev/null
Require valid-user[/code]
16. transforms the old domain name into a new domain name
[code]# redirect from.