<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[静怡家园]]></title> 
<link>http://www.zhanghaijun.com/index.php</link> 
<description><![CDATA[书山有路勤为径，学海无涯苦作舟！]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[静怡家园]]></copyright>
<item>
<link>http://www.zhanghaijun.com/post//</link>
<title><![CDATA[Apache下实现301永久性重定向的方法]]></title> 
<author>碟舞飞扬 &lt;webmaster@zhanghaijun.com&gt;</author>
<category><![CDATA[服务器类]]></category>
<pubDate>Sat, 14 May 2011 18:35:57 +0000</pubDate> 
<guid>http://www.zhanghaijun.com/post//</guid> 
<description>
<![CDATA[ 
	1. Apache模块 mod_alias的 Redirect 和 RedirectMatch命令<br/> <br/>上面提到2个命令使用方法相似。而区别就是后者RedirectMatch基于正则表达式匹配对当前的URL发送一个外部重定向语法为：<br/> <br/>Redirect ［status］ URL-path URL<br/> <br/>RedirectMatch ［status］ regex URL<br/> <br/>status参数可以使用以下HTTP状态码：<br/> <br/>permanent<br/> <br/>返回一个永久性重定向状态码（301），表示此资源的位置变动是永久性的。<br/> <br/>temp<br/> <br/>返回一个临时性重定向状态码（302），这是默认值。<br/> <br/>seeother<br/> <br/>返回一个“参见”状态码（303），表示此资源已经被替代。<br/> <br/>gone<br/> <br/>返回一个“已废弃”状态码（410），表示此资源已经被永久性地删除了。如果指定了这个状态码，则URL参数将被忽略。<br/> <br/>举例：<br/> <br/>APACHE<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>Redirect 301 /old/old.htm http://www.abc.com/new.htm<br/>Redirect permanent /one http://abc.com/two<br/>RedirectMatch 301 (.*).gif$ http://www.abc.com/images/$1.jpg<br/></div></div><br/>2.使用mod_rewrite重写URL方式<br/> <br/>APACHE<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>Options +FollowSymLinks<br/>RewriteEngine on<br/>RewriteCond %&#123;HTTP_HOST&#125; ^abc.com<br/>RewriteRule ^(.*)$ http://www.abc.com/$1 [R=permanent,L]<br/></div></div><br/>在这里判断当前服务器变量HTTP_HOST是否等于abc.com，为真就进行重写，按照R=permanent进行永久重定向，L表示并立即停止重写操作，并不再应用其他重写规则<br/> <br/>下面是我最终实现的.htaccess文件，同时也并入wordpress重写规则。<br/> <br/>APACHE<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/># BEGIN WordPress<br/> <IfModule mod_rewrite.c><br/> RewriteEngine On<br/> #Redirect<br/> Options +FollowSymLinks<br/> RewriteCond %&#123;HTTP_HOST&#125; ^abc.com$<br/> RewriteCond %&#123;HTTP_HOST&#125; !^$<br/> RewriteRule ^(.*)$ http://www.abc.com/$1 [R=301,L]<br/> #Rewrite(blog)<br/> RewriteCond %&#123;REQUEST_FILENAME&#125; !-f<br/> RewriteCond %&#123;REQUEST_FILENAME&#125; !-d<br/> RewriteRule ^blog/.* /blog/index.php [L]<br/> RewriteRule . -<br/></IfModule><br/> # END WordPress<br/></div></div><br/>Tags - <a href="http://www.zhanghaijun.com/tags/apache/" rel="tag">apache</a> , <a href="http://www.zhanghaijun.com/tags/301%25E6%25B0%25B8%25E4%25B9%2585%25E9%2587%258D%25E5%25AE%259A%25E5%2590%2591/" rel="tag">301永久重定向</a>
]]>
</description>
</item><item>
<link>http://www.zhanghaijun.com/post//#blogcomment</link>
<title><![CDATA[[评论] Apache下实现301永久性重定向的方法]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.zhanghaijun.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>