<?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>憂藍夢境‧部落格 &#187; 固定網址</title>
	<atom:link href="http://blog.linym.net/archives/tag/%e5%9b%ba%e5%ae%9a%e7%b6%b2%e5%9d%80/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.linym.net</link>
	<description>我的學習心得、筆記</description>
	<lastBuildDate>Fri, 09 Dec 2011 12:33:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>[WordPress] 在 IIS 使用固定網址(Permalink)</title>
		<link>http://blog.linym.net/archives/319</link>
		<comments>http://blog.linym.net/archives/319#comments</comments>
		<pubDate>Thu, 08 Jan 2009 03:42:20 +0000</pubDate>
		<dc:creator>lym520</dc:creator>
				<category><![CDATA[Server]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[程式筆記]]></category>
		<category><![CDATA[系統筆記]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[Permalinks]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[固定網址]]></category>

		<guid isPermaLink="false">http://blog.linym.net/?p=319</guid>
		<description><![CDATA[Apache 有個非常強大好用的 mod_rewrite 模組，可以實現 URL Rewriting，運用在網站或部落格對 SEO 會有幫助。WP 的固定網址也是這類的運用，一般架設在 Apache 不會有什麼問題，只要有啟用 mod_rewrite 就 OK，不過如果是裝在 IIS 上，那就會看到很醜的 /index.php/aaa/bbb/123 這樣的網址，本篇就是教大家如何讓 IIS 真正擁有 rewrite 的功能。 首先必須安裝 for IIS 的擴充，微軟有針對 IIS7 開發一套 URL Rewrite Module，不過 IIS6 就只能用別的，測試很多套最後選擇 ISAPI_Rewrite，因為它幾乎相容 .htaccess、mod_rewrite 語法，也比較穩定，ISAPI_Rewrite 有分要錢的 full 版和免費的 Lite 版，差異請看這篇，目前選 Lite 就夠用了。 Step 1 先設定 WordPress ，進入後台選擇想要的固定網址格式，如「/%year%/%monthnum%/%day%/%postname%.html」，記得把前面 index.php 拿掉。 Step 2 安裝好 ISAPI_Rewrite 3 [...]]]></description>
			<content:encoded><![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&#038;g=6&#038;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 />
<img src="http://blog.linym.net/wp-content/uploads/2009/01/e693b7e58f96.jpg" alt="固定網址" title="固定網址" width="624" height="324" class="alignnone size-full wp-image-330" /></p>
<p><strong>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網址為 http://aaa.domain.com/blog/
RewriteCond %{HTTP_HOST} ^aaa\.domain\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/blog/ /blog/index\.php [L]

# 假設WP網址為 http://bbb.domain.com
RewriteCond %{HTTP_HOST} ^bbb\.domain\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index\.php [L]
</pre>
<p><strong>Step 3</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');

// 找到
$req_uri = $_SERVER['REQUEST_URI'];
// 改成
$req_uri = mb_convert_encoding($_SERVER['REQUEST_URI'], 'UTF-8', 'BIG5');
</pre>
<p>這樣就正常了。註：PHP 必須啟用 mbstring。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.linym.net/archives/319/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

