Lamp--apache prohibit designation of User_agent

Source: Internet
Author: User

User_agent can be used as a browser logo, the current mainstream browser has IE, Chrome, Firefox, 360, the iphone Safari, Android phone Baidu search engine, Google search engine, and so on, each browser has a corresponding User_agent, a few common user_agent are listed below.

mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; trident/4.0;. net4.0c;. net4.0e; SE 2.x)

mozilla/5.0 (Windows NT 5.1) applewebkit/537.36 (khtml,like Gecko) chrome/31.0.1650.63 safari/537.36

mozilla/5.0 (compatible; baiduspider/2.0; +http://www.baidu.com/search/spider.html)

mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; WOW64; trident/4.0; SLCC2;. NET CLR 2.0.50727;. NET CLR 3.5.30729;. NET CLR 3.0.30729; Media Center PC 6.0;. net4.0c;. net4.0e; infopath.3; 360SE)

Make some restrictions on user_agent.

The configuration is as follows:

<ifmodule mod_rewrite.c>

Rewriteengine on

Rewritecond%{http_user_agent} ^*firefox/4.0* [Nc,or]

Rewritecond%{http_user_agent} ^*tomato bot/1.0* [NC]

Rewriterule. *-[F]

</IfModule>

Also use the rewrite module to implement the restriction specified user_agent, in this case, Rewriterule. *-[F] can be directly forbidden to access, Rewritecond with User_agent to match, *firefox/4.0* said, as long as US The er_agent contains firefox/4.0 to match the criteria, where * denotes any character, NC means case insensitive, or indicates or joins the next condition. If you want to limit Baidu's search engine, you can add a rule like this:

Rewritecond%{http_user_agent} ^*baiduspider/2.0* [NC]

Rewriterule. *-[F]

Since there is or OR, it has to be and, as long as you do not write or is and mean.


This article is from the "Learn Notes for students" blog, please make sure to keep this source http://sanyisheng.blog.51cto.com/11154168/1795826

Lamp--apache prohibit designation of User_agent

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.