<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Xqlab's Blog &#187; Rewrite</title>
	<atom:link href="http://www.xqlab.com/html/ytag/rewrite/feed" rel="self" type="application/rss+xml" />
	<link>http://www.xqlab.com</link>
	<description>一个研究电脑和网络等IT技术的实验室</description>
	<lastBuildDate>Sat, 21 Aug 2010 10:37:17 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>利用Rewrite规则封掉对方的IP</title>
		<link>http://www.xqlab.com/html/y2008/195.html</link>
		<comments>http://www.xqlab.com/html/y2008/195.html#comments</comments>
		<pubDate>Mon, 24 Nov 2008 12:51:36 +0000</pubDate>
		<dc:creator>xqlab</dc:creator>
				<category><![CDATA[互联网络]]></category>
		<category><![CDATA[设计研究]]></category>
		<category><![CDATA[IP]]></category>
		<category><![CDATA[Rewrite]]></category>

		<guid isPermaLink="false">http://www.xqlab.com/?p=195</guid>
		<description><![CDATA[很多情况下，某个 IP 的访问很容易造成 CPU 100% （比如 某些搜索引擎的固定抓取，别人大量的采集站点），这个时候我们就要利用一些有效的手段封掉对方的 IP，让他无法消耗服务器的资源，... ]]></description>
			<content:encoded><![CDATA[<p>很多情况下，某个 IP 的访问很容易造成 CPU 100% （比如 某些搜索引擎的固定抓取，别人大量的采集站点），这个时候我们就要利用一些有效的手段封掉对方的 IP，让他无法消耗服务器的资源，封 IP 的方法有很多种，如果你的 Web 服务器安装了 Rewrite 模块的话，也可以试试利用 Rewrite 规则封掉对方的 IP。</p>
<p>　　1、例如我们把某个特定的 IP 直接重定向到 baidu 首页，在网站根目录的 .htaccess 文件里添加代码：</p>
<p>　　RewriteCond %{REMOTE_ADDR} 192.168.1.1 [NC]</p>
<p>　　RewriteRule ^(.*)$ http://www.baidu.com/$1 [R=301]</p>
<p>　　将 192.168.1.1 这个 IP 替换成您要限制的 IP 即可</p>
<p>　　2、如果要实现多个 IP ，可以这样写：</p>
<p>　　RewriteCond %{REMOTE_ADDR} 192.168.1.1 [OR]</p>
<p>　　RewriteCond %{REMOTE_ADDR} 192.168.1.2 [NC]</p>
<p>　　RewriteRule ^(.*)$ http://www.baidu.com/$1 [R=301]</p>
<p>其实就是个301重定向。<br />
<h3>随机日志</h3>
<ul class="related_post">
<li><a href="http://www.xqlab.com/html/y2008/170.html" title="如何建一个别人打不开的文件夹">如何建一个别人打不开的文件夹</a></li>
<li><a href="http://www.xqlab.com/html/y2008/3.html" title="别让生命留下遗憾">别让生命留下遗憾</a></li>
<li><a href="http://www.xqlab.com/html/y2009/278.html" title="章子怡与男友海边度假遭遇偷拍，艳照流传网络~">章子怡与男友海边度假遭遇偷拍，艳照流传网络~</a></li>
<li><a href="http://www.xqlab.com/html/y2008/253.html" title="内存不能为Read的原因总结">内存不能为Read的原因总结</a></li>
<li><a href="http://www.xqlab.com/html/y2008/205.html" title="Windows XP：共享经典问题详细拆解">Windows XP：共享经典问题详细拆解</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.xqlab.com/html/y2008/195.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
