<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[Yon Faith]]></title> 
<link>http://blog.ongod.org/index.php</link> 
<description><![CDATA[音乐信仰.. 旅行家]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[Yon Faith]]></copyright>
<item>
<link>http://blog.ongod.org/read.php/702.htm</link>
<title><![CDATA[[WordPress] 在 IIS 使用固定網址(Permalink)]]></title> 
<author>liuxyon &lt;info_yon@yahoo.com.cn&gt;</author>
<category><![CDATA[Technology]]></category>
<pubDate>Sat, 11 Apr 2009 13:14:29 +0000</pubDate> 
<guid>http://blog.ongod.org/read.php/702.htm</guid> 
<description>
<![CDATA[ 
	<p>Apache 有個非常強大好用的 mod_rewrite 模組，可以實現 URL Rewriting，運用在網站或部落格對 SEO 會有幫助。WP 的固定網址也是這類的運用，一般架設在 Apache 不會有什麼問題，只要有啟用 mod_rewrite 就 OK，不過如果是裝在 IIS 上，那就會看到很醜的 /<strong>index.php</strong>/aaa/bbb/123 這樣的網址，本篇就是教大家如何讓 IIS 真正擁有 rewrite 的功能。</p><p>首先必須安裝 for IIS 的擴充，微軟有針對 IIS7 開發一套 <a href="http://www.iis.net/downloads/default.aspx?tabid=34&amp;g=6&amp;i=1691" target="_blank">URL Rewrite Module</a>，不過 IIS6 就只能用別的，測試很多套最後選擇 <a href="http://www.helicontech.com/isapi_rewrite/" target="_blank">ISAPI_Rewrite</a>，因為它幾乎相容 .htaccess、mod_rewrite 語法，也比較穩定，ISAPI_Rewrite 有分要錢的 full 版和免費的 Lite 版，差異請看<a href="http://www.helicontech.com/isapi_rewrite/doc/litever.htm" target="_blank">這篇</a>，目前選 Lite 就夠用了。</p><p><strong>Step 1</strong><br />先設定 WordPress ，進入後台選擇想要的固定網址格式，如「/%year%/%monthnum%/%day%/%postname%.html」，記得把前面 index.php 拿掉。<br /><br /><img class="insertimage" src="attachment.php?fid=43" border="0" width="524" height="324" /><br /><br /><br /><br /></p><p><strong><br /><br />Step 2</strong><br />安裝好 <a href="http://www.helicontech.com/download-isapi_rewrite3.htm" target="_blank">ISAPI_Rewrite 3 Lite</a>，編輯安裝目錄下的 httpd.conf 設定檔，內容範例：</p><pre># 假設WP網址為 <a href="http://aaa.domain.com/blog/" target="_blank">http://aaa.domain.com/blog/</a> RewriteCond %&#123;HTTP_HOST&#125; ^aaa&#92;.domain&#92;.com$ [NC] RewriteCond %&#123;REQUEST_FILENAME&#125; !-f RewriteCond %&#123;REQUEST_FILENAME&#125; !-d RewriteRule ^/blog/ /blog/index&#92;.php [L]&nbsp;&nbsp;# 假設WP網址為 <a href="http://bbb.domain.com" target="_blank">http://bbb.domain.com</a> RewriteCond %&#123;HTTP_HOST&#125; ^bbb&#92;.domain&#92;.com$ [NC] RewriteCond %&#123;REQUEST_FILENAME&#125; !-f RewriteCond %&#123;REQUEST_FILENAME&#125; !-d RewriteRule . /index&#92;.php [L] </pre><p><strong><br />Step 3<br /></strong><br />基本上完成前兩個動作固定網址就可以運作了，但是如果網址帶有中文就會發生 404 錯誤，原因可以參考<a href="http://www.zu14.cn/2008/12/13/wordpress_iis_cn/" target="_blank">這篇</a>，修改 wp-includes/classes.php</p><pre>// 找到 $pathinfo = $_SERVER['PATH_INFO']; // 改成 $pathinfo = mb_convert_encoding($_SERVER['PATH_INFO'], 'UTF-8', 'BIG5');&nbsp;&nbsp;// 找到 $req_uri = $_SERVER['REQUEST_URI']; // 改成 $req_uri = mb_convert_encoding($_SERVER['REQUEST_URI'], 'UTF-8', 'BIG5'); </pre><p>這樣就正常了。註：PHP 必須啟用 mbstring。<br /><br /></p>
]]>
</description>
</item>
</channel>
</rss>