The role of the. htaccess file (Access control)

Source: Internet
Author: User

Online tool: Http://www.htaccesseditor.com/sc.shtml

Speaking of. htaccess file, I think for WordPress novice or veteran should not be very familiar with, there is not much of this concept, at least the small part is such, and recently saw an article about the introduction, feel very good, so today intends to share to everyone, also give yourself a literacy lesson!

Let's start by describing what the. htaccess file is,. htaccess is an Apache HTTP Server system-level profile that is typically used to implement features other than the host itself, such as redirection, Gzip, and access restrictions ...

So here's a look at 10 of the magical properties of the. htaccess file to see how much you know

1. Redirect (301 jump)

Believe that this function, we are not unfamiliar, in order to focus on the weight of the website domain name, usually will not take the WWW domain name 301 to the domain name with www, For example, the site's domain name 2zzt.com will automatically jump to www.2zzt.com up, the advantage is that the search engine will focus on the domain name of the WWW page with www page weight, if not done 301 redirect, and with www and without WWW domain can access the same site, then in search The optimization of the cable engine will play the disadvantage of decentralized weight! What to do: (replace the domain name with your own paste in the. htaccess file)

    1. Rewriteengine on
    2. Rewritecond%{http_host}!^2zzt.com$ [NC]
    3. Rewriterule ^ (. *) $ http://www.2zzt.com/$1 [l,r=301]
2, anti-theft chain function

Indeed, the. htaccess file can open the anti-theft chain function, what is called the anti-theft chain? Anti-theft chain is to save the site's traffic, the site's files, pictures, etc. can only be displayed on their own website domain name, to avoid other sites to call their own website files and lost a lot of traffic, for many small webmaster, the host is a traffic limit. Specific operation:

    1. Rewriteengine on
    2. Rewritecond%{http_referer}!^http://(. +\.)? 2zzt\.com/[NC]
    3. Rewritecond%{http_referer}!^$
    4. # wordpress Theme Download Station reminder:/notlink.png for the hotlinking display of the picture, it is recommended to use small size, lest because the picture is too big, two times wasted!
    5. Rewriterule. *\. (jpe?g|gif|bmp|png) $/notlink.png [L]
3, the WordPress feed source for 301 redirect

Speaking of this function, to be honest, the small part is still very unfamiliar, the reason is that the small series has not used the function of the feed, of course, if you use the WordPress feed source, here to skip it, Because this feature is for those who do not use the source of WordPress feed friends can help webmaster standardize the feed source, the specific operation:

    1. Redirectmatch 301/feed/(atom|rdf|rss|rss2)/?$ http://feeds.2zzt.com/wordpress-admin/
    2. Redirectmatch 301/comments/feed/(atom|rdf|rss|rss2)/?$ http://feeds.2zzt.com/wordpress-admin/
4, the host error page definition

This function is relative to the use of the virtual host, it may have been related to the settings, but if it is to build their own environment, I believe that the need to use, the specific operation:

      1. ErrorDocument 400/errors/badrequest.html
      2. ErrorDocument 401/errors/authreqd.html
      3. ErrorDocument 403/errors/forbid.html
      4. ErrorDocument 404/errors/notfound.html
      5. ErrorDocument 500/errors/serverr.html

The role of the. htaccess file (Access control)

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.