6_apache Configuration of the User_agent

Source: Internet
Author: User

User_agent: Restrict some junk access


650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/88/48/wKioL1ft4DCAQrgxAAXKwe7WQGc406.jpg "title=" Dis23.jpg "alt=" Wkiol1ft4dcaqrgxaaxkwe7wqgc406.jpg "/>

Under this module, add the Red font section.

[Email protected] logs]# vim/usr/local/apache2/conf/extra/httpd-vhosts.conf

<ifmodule mod_rewrite.c>

Rewriteengine on

Rewritecond%{http_host} ^www.aaa.com$ [or]

Rewritecond%{http_host} ^www.bbb.com$

Rewriterule ^/(. *) $ http://www.test.com/$1 [r=301,l]

Rewritecond%{http_user_agent} ^.*curl.* [Nc,or] #NC case insensitive

Rewritecond%{http_user_agent} ^.*chrome* [NC]

Rewriterule. *-[F]


</IfModule>


[Email protected] logs]# apachectl-t

Syntax OK

[Email protected] logs]# apachectl restart

[Email protected] logs]# curl-x127.0.0.1:80 www.test.com/data/forum.php

<! DOCTYPE HTML PUBLIC "-//ietf//dtd HTML 2.0//en" >

<title>403 forbidden</title> #都禁掉了, cannot access

<p>you don ' t has permission to access/data/forum.php

On this server.</p>

</body>

[Email protected] logs]# curl-x127.0.0.1:80 www.test.com/98989898

<! DOCTYPE HTML PUBLIC "-//ietf//dtd HTML 2.0//en" >

<title>403 forbidden</title>

<p>you don ' t has permission to access/98989898

On this server.</p>

</body>



Comment out this line

#Rewritecond%{http_user_agent} ^.*curl.* [Nc,or] #NC case insensitive

You can access it.

[Email protected] logs]# curl-x127.0.0.1:80 Www.test.com/forum.php-I

http/1.1 OK

Date:fri, Sep 05:54:07 GMT

server:apache/2.2.31 (Unix) php/5.6.24

x-powered-by:php/5.6.24

SET-COOKIE:K1RM_2132_SALTKEY=UQKNMBNM; Expires=sun, 30-oct-2016 05:54:07 GMT; max-age=2592000; path=/; HttpOnly

set-cookie:k1rm_2132_lastvisit=1475211247; Expires=sun, 30-oct-2016 05:54:07 GMT; max-age=2592000; path=/

Set-cookie:k1rm_2132_sid=qvdltx; Expires=sat, 01-oct-2016 05:54:07 GMT; max-age=86400; path=/

set-cookie:k1rm_2132_lastact=1475214847%09forum.php%09; Expires=sat, 01-oct-2016 05:54:07 GMT; max-age=86400; path=/

Set-cookie:k1rm_2132_onlineusernum=1; Expires=fri, 30-sep-2016 05:59:07 GMT; max-age=300; path=/

Set-cookie:k1rm_2132_sid=qvdltx; Expires=sat, 01-oct-2016 05:54:07 GMT; max-age=86400; path=/

Cache-control:max-age=0

Expires:fri, Sep 05:54:07 GMT

content-type:text/html; Charset=gbk


Analog access

[Email protected] logs]# curl-a welcometobeijingchrome-x127.0.0.1:80 Www.test.com/forum.php-I

http/1.1 403 Forbidden

Date:fri, Sep 05:57:35 GMT

server:apache/2.2.31 (Unix) php/5.6.24

content-type:text/html; Charset=iso-8859-1

If you have chrome in the word, you can't access it.

This article is from the "Cbo#boy_linux Road" blog, make sure to keep this source http://20151213start.blog.51cto.com/9472657/1858125

6_apache Configuration of the 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.