What is the. htaccess?

Source: Internet
Author: User
Tags cpanel password protection

. Htaccess is called a distributed configuration file, which provides a way to change the configuration of a directory by placing a file containing one or more instructions in a particular document directory to act on this directory and all its subdirectories. and the directives in the subdirectories overwrite the higher-level directories or the directives in the master server configuration file. In general, if your virtual host is using a UNIX or Linux system, or any version of the Apache Web server, it is theoretically supported. htaccess.
What is the. htaccess? htaccess is a file that is set up under various permissions rules for the system directory under the Apache HTTP Server installation software, which exists in the Linux operating system.  More common is the definition of the default home page name, 404 pages, 301 turn, and so on, there are more features such as pseudo-static, limit the picture outside the chain, limit the download, password protection, remove page ads, and so on, there are a lot of features are not listed. In fact, most of these functions can be set in the Cpanel Control Panel (the equivalent of the graphical interface of the. htaccess). But for the master, cpanel for htaccess to provide the function is too little point, manual editing is kingly.
Custom error page (direct copy)

ErrorDocument 404 /error-pages/not-found.htmlErrorDocument 503 /error-pages/service-unavailable.html

IP Disable

Order allow,denyDeny from 123.45.67.8Deny from 123.123.7Allow from all

Above can prohibit the IP address in the 123.45.67.8 and the IP address at the beginning of 123.123.7 for anyone. For example, 123.123.74.42 cannot be accessed.
Change default Home Page
DirectoryIndex homepage.html
Remove Page ads (all free spaces are not necessarily available)

LayoutIgnoreURI *.phpLayoutIgnoreURI *.cgiLayoutIgnoreURI *.htmLayoutIgnoreURI *.htmlLayoutIgnoreURI *.txt

Page Jump
Redirect page1.html page2.html
If someone accesses http://www.example.com/page1.html, he will be redirected to the http://www.example.com/page2.html (with HTTP status code 302)
server built-in SSI SSI's use of detailed

AddType text/html .shtmlAddHandler server-parsed .shtmlOptions Indexes FollowSymLinks Includes

Prevents the. htaccess rule behind the image hot chain from using the MoD rewrite.
Special Domain Name

RewriteEngine onRewriteCond %{HTTP_REFERER} ^http://([^/]+\.)?baddomain1\.com [NC,OR]RewriteCond %{HTTP_REFERER} ^http://([^/]+\.)?baddomain2\.com [NC,OR]RewriteCond %{HTTP_REFERER} ^http://([^/]+\.)?baddomain3\.com [NC]RewriteRule \.(gif|jpg)$ http://www.example.com/hotlink.gif [R,L]

Non-special domain name

RewriteEngine onRewriteCond %{HTTP_REFERER} !^$RewriteCond %{HTTP_REFERER} !^http://(www\.)?example.com/.*$ [NC]RewriteRule \.(gif|jpg)$ http://www.example.com/hotlink.gif [R,L]

Unless example.com has this image, the browser can see Hotlink.gif.
Note: Hotlink hot chain protection uses the. htaccess relies on the client to send the correct "commit" value in an HTTP GET request.
Prohibit. htaccess files from being viewed
Add the following code to your. htaccess file to prevent others from accessing your. htaccess file:

<Files .htaccess>order allow,denydeny from all</Files>

Most versions of this web site have errors, most versions lose <files .htaccess>, resulting in all files being blocked from access. If you use the wrong rules, all of your content will not be accessible.

Similarly, if you want to prohibit access to other files, you can replace them with other filenames.



Jasonqiao
Links: http://www.jianshu.com/p/ddca040c8d48
Source: Pinterest
Copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source.

What is the. htaccess?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.