<?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>Eric&#039;s Who Know &#187; mod_rewrite</title> <atom:link href="http://who-know.com/tag/mod_rewrite/feed/" rel="self" type="application/rss+xml" /><link>http://who-know.com</link> <description>C&#039;est La Vie</description> <lastBuildDate>Mon, 17 May 2010 22:21:05 +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>修改 WordPress Login、Logout、Register、wp-admin 位置</title><link>http://who-know.com/how-to-hide-wp-admin-folder-name-on-wordpress/</link> <comments>http://who-know.com/how-to-hide-wp-admin-folder-name-on-wordpress/#comments</comments> <pubDate>Thu, 04 Feb 2010 19:20:39 +0000</pubDate> <dc:creator>Eric</dc:creator> <category><![CDATA[Free Teaching]]></category> <category><![CDATA[.htaccess]]></category> <category><![CDATA[mod_rewrite]]></category> <category><![CDATA[Stealth Login]]></category> <category><![CDATA[WordPress]]></category><guid isPermaLink="false">http://who-know.com/?p=97</guid> <description><![CDATA[00. 修改 WordPress 後台地址 http://your.domain.name/wp-admin/ to http://your.domain.name/whatever-you-want/
01. 下載 Stealth Login 並解壓上傳到 ./wp-content/plugins/ 下。
// 或從 WordPress 後台直接搜尋 Stealth Login 下載
02. Plugins -> Installed -> Activate Stealth Login
03. WordPress 後台 -> Settings -> Stealth Login
04. 把 Enable Plugin 切換到 On，然後依據您的需要來設定您想要的網址形式，含 WordPress 登入、登出、註冊、後台的位置。
eg :
Login Slug : in -> http://who-know.com/in/；Logout Slug : out -> http://who-know.com/out/；Register Slug : reg -> [...]]]></description> <content:encoded><![CDATA[<p>00. 修改 <a href="http://wordpress.org/" target="_blank">WordPress</a> 後台地址 http://your.domain.name/wp-admin/ to http://your.domain.name/whatever-you-want/</p><p>01. 下載 <a href="http://wordpress.org/extend/plugins/stealth-login/" target="_blank">Stealth Login</a> 並解壓上傳到 ./wp-content/plugins/ 下。<br /> // 或從 <a href="http://wordpress.org/" target="_blank">WordPress</a> 後台直接搜尋 <a href="http://wordpress.org/extend/plugins/stealth-login/" target="_blank">Stealth Login</a> 下載</p><p>02. Plugins -> Installed -> Activate <a href="http://wordpress.org/extend/plugins/stealth-login/" target="_blank">Stealth Login</a></p><p>03. <a href="http://wordpress.org/" target="_blank">WordPress</a> 後台 -> Settings -> <a href="http://wordpress.org/extend/plugins/stealth-login/" target="_blank">Stealth Login</a><span id="more-97"></span></p><p>04. 把 Enable Plugin 切換到 On，然後依據您的需要來設定您想要的網址形式，含 <a href="http://wordpress.org/" target="_blank">WordPress</a> 登入、登出、註冊、後台的位置。</p><p>eg :<br /> Login Slug : in -> http://who-know.com/in/；Logout Slug : out -> http://who-know.com/out/；Register Slug : reg -> http://who-know.com/reg/；Admin Slug : admin -> http://who-know.com/admin/</p><p>05. 把 Stealth Mode 切換到 Enable，不然就變成 http://who-know.com/reg/ = http://who-know.com/wp-login.php?action=register 兩種網址形式都可以用來註冊帳號，這樣就沒有達到保護 <a href="http://wordpress.org/" target="_blank">WordPress</a> 的用意了，我們希望的是透過修改 <a href="http://wordpress.org/" target="_blank">WordPress</a> 登入、登出、註冊、後台的網址，來保護我們用心經營的聖地。</p><p>06. 最後它會生成一大串的語法加到 .htaccess file，接下來請立刻測試有沒有成功，如果您的 <a href="http://wordpress.org/" target="_blank">WordPress</a> 是安裝在子目錄的且有使用 Permalink( 中譯 : 永久連結、固定網址、偽靜態等 )，可能會有問題。</p><p>eg : 假設您的 <a href="http://wordpress.org/" target="_blank">WordPress</a> 原本是裝在 ./wordpress/ 下，您會發現剛才改的網址變成 http://your.domain.name/wordpress/wordpress/ ...，所以請下載 .htaccess file 把 RewriteBase /wordpress/ 修正一下再上傳覆蓋，即可解決問題了。<br /> // 把 RewriteBase /wordpress/ 改成 RewriteBase /</p><pre class="brush: bash;">
# BEGIN WordPress
&lt;IfModule mod_rewrite.c&gt;
RewriteEngine On
RewriteBase /wordpress/
# STEALTH-LOGIN
...
# END STEALTH-LOGIN
...
&lt;/IfModule&gt;

# END WordPress
</pre><p>07. 附註<br /> a. 設定好後，把 ./wp-content/plugins/ 下的 stealth-login 刪除，好像也可以正常運作。<br /> b. 無聊也可以定期幫它換一下 stealth_folderName_key<br /> // <a href="http://wordpress.org/" target="_blank">WordPress</a> 後台 -> Settings -> <a href="http://wordpress.org/extend/plugins/stealth-login/" target="_blank">Stealth Login</a> -> Save Changes</p><p>Ref : // 紀錄一下其它方法，其中第二個方法很原始也很暴力<br /> 01. <a href="http://www.michiknows.com/2007/02/12/who-else-wants-to-hide-their-wordpress-admin-folder/" target="_blank">Who Else Wants to Hide Their Wordpress Folder?</a><br /> 02. <a href="http://www.socialblogr.com/2009/09/how-to-change-folder-name-on-wordpress.html>" target="_blank">How To Change "wp-admin" Folder Name on Wordpress</a></p> ]]></content:encoded> <wfw:commentRss>http://who-know.com/how-to-hide-wp-admin-folder-name-on-wordpress/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>我的網址由我做主 non-www or www</title><link>http://who-know.com/301-redirect-from-non-www-to-www-by-htaccess/</link> <comments>http://who-know.com/301-redirect-from-non-www-to-www-by-htaccess/#comments</comments> <pubDate>Wed, 07 Oct 2009 19:21:08 +0000</pubDate> <dc:creator>Eric</dc:creator> <category><![CDATA[Free Teaching]]></category> <category><![CDATA[.htaccess]]></category> <category><![CDATA[Apache]]></category> <category><![CDATA[mod_rewrite]]></category><guid isPermaLink="false">http://who-know.com/?p=87</guid> <description><![CDATA[00. 如果您想一統天下, 讓 non-www url 在網址前面都加上 www 或您想把 www url 的 www 都去掉。因為搜尋引擎會視 non-www 和 www 為兩個不同的網站, 為了 SEO 著想, 或者是想讓搜尋引擎, 固定都收錄 non-www or www 的網址, 而不會三心二意, 一下收錄 non-www 一下收錄 www。01. Redirect Non-WWW to WWW
//  eg: Redirect who-know.com to www.who-know.com, 於 .htaccess file 加上# 301 Redirect Non-WWW to WWW
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(who-know\.com)(:80)? [NC]
RewriteRule ^(.*) [...]]]></description> <content:encoded><![CDATA[<p>00. 如果您想一統天下, 讓 non-www url 在網址前面都加上 www 或您想把 www url 的 www 都去掉。因為搜尋引擎會視 non-www 和 www 為兩個不同的網站, 為了 SEO 著想, 或者是想讓搜尋引擎, 固定都收錄 non-www or www 的網址, 而不會三心二意, 一下收錄 non-www 一下收錄 www。<br /> <span id="more-87"></span><br /> 01. Redirect Non-WWW to WWW<br /> //  eg: Redirect who-know.com to www.who-know.com, 於 .htaccess file 加上</p><pre class="brush: bash;">
# 301 Redirect Non-WWW to WWW
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(who-know\.com)(:80)? [NC]
RewriteRule ^(.*) http://www.who-know.com/$1 [R=301,L]
</pre><p>02. Redirect WWW to Non-WWW<br /> //  eg: Redirect www.who-know.com to who-know.com, 於 .htaccess file 加上</p><pre class="brush: bash;">
# 301 Redirect WWW to Non-WWW
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.who-know\.com)(:80)? [NC]
RewriteRule ^(.*) http://who-know.com/$1 [R=301,L]
</pre><p>03. 如果覺得自己改有點麻煩, 可以利用線上製作 .htaccess file ( <a href="http://www.htaccesseditor.com/tc.shtml" target="_blank">繁</a> <a href="http://htaccesseditor.com/sc.shtml" target="_blank">簡</a> <a href="http://htaccesseditor.com/en.shtml" target="_blank">英</a> <a href="http://htaccesseditor.com/" target="_blank">日</a> ) 來產生, 點左邊的設置WWW(w) -> 然後填上您希望統一的網址 -> 複製貼上到您的 .htaccess file<br /> //  參考上面舉的例子, 複製須要的部分即可, 用不到的就不用管它。</p><pre class="brush: bash;">
&lt;Files ~ &quot;^.(htaccess|htpasswd)$&quot;&gt;
deny from all
&lt;/Files&gt;
order deny,allow
</pre><p>04. 上傳完 .htaccess file, 可以利用 <a href="http://news.stepforth.com/seo-tools/http-header-checker.php" target="_blank">HTTP Server Header Checker</a>, <a href="http://www.seochat.com/seo-tools/redirect-check/" target="_blank">SEO Tools - Search Engine Friendly Redirect Checker</a> 來檢查是否設定成功。</p><p><a href="http://pic.who-know.com/Single/Search_Engine_Friendly_Redirect_Checker_001.png" class="highslide-image" onclick="return hs.expand(this);" target="_blank"><img class="doCenter" src="http://pic.who-know.com/Single/Search_Engine_Friendly_Redirect_Checker_001.png" alt=""/></a></p><p><a href="http://pic.who-know.com/Single/HTTP_Server_Header_Checker_001.png" class="highslide-image" onclick="return hs.expand(this);" target="_blank"><img class="doCenter" src="http://pic.who-know.com/Single/HTTP_Server_Header_Checker_001.png" alt=""/></a></p><p>05. 關於上面 Rewrite Rule 所用到的 NC, $1, R, L 的解釋</p><p>&nbsp;&nbsp;a. [NC] (no case) Case-insensitive, ignoring difference between 'A-Z' and 'a-z' when Pattern is matched against the current URL.</p><p>&nbsp;&nbsp;b. $1 is magically replaced with the text which was captured previously. ( $ stuff means plug in whatever follows )</p><p>&nbsp;&nbsp;c. L - Last Rule. No more rules will be proccessed if this one was successful.</p><p>&nbsp;&nbsp;d. R[=code] - Redirect. The user's web browser will be visibly redirected to the substituted URL. If you use this flag, you must prefix the substitution with http://www.somesite.com/, thus making it into a true URL. If no code is given, then a HTTP reponse of 302 (temporarily moved) is sent.</p><p>06. 另外, 大家常說的 301、302, 實際上是 301、307?</p><p>&nbsp;&nbsp;a. <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.2" target="_blank">301 Moved Permanently</a></p><blockquote><p>The requested resource has been assigned a new permanent URI and any future references to this resource SHOULD use one of the returned URIs. Clients with link editing capabilities ought to automatically re-link references to the Request-URI to one or more of the new references returned by the server, where possible. This response is cacheable unless indicated otherwise.</p><p>The new permanent URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s).</p><p>If the 301 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.</p></blockquote><p>&nbsp;&nbsp;b. <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.3" target="_blank">302 Found</a></p><blockquote><p>The requested resource resides temporarily under a different URI. Since the redirection might be altered on occasion, the client SHOULD continue to use the Request-URI for future requests. This response is only cacheable if indicated by a Cache-Control or Expires header field.</p><p>The temporary URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s).</p><p>If the 302 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.</p></blockquote><p>&nbsp;&nbsp;c. <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.8" target="_blank">307 Temporary Redirect</a></p><blockquote><p>The requested resource resides temporarily under a different URI. Since the redirection MAY be altered on occasion, the client SHOULD continue to use the Request-URI for future requests. This response is only cacheable if indicated by a Cache-Control or Expires header field.</p><p>The temporary URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s) , since many pre-HTTP/1.1 user agents do not understand the 307 status. Therefore, the note SHOULD contain the information necessary for a user to repeat the original request on the new URI.</p><p>If the 307 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.</p></blockquote><p>08. 由於實在太好奇 302 v.s. 307, 於是又 <a href="http://www.google.com/" target="_blank">Google</a> 了一下, 終於發現原因了, 原來一個是 <a href="http://www.w3.org/Protocols/HTTP/1.0/spec.html" target="_blank">HTTP/1.0 Hypertext Transfer Protocol</a> (下面), 一個是 <a href="http://www.w3.org/Protocols/rfc2616/rfc2616.html" target="_blank">HTTP/1.1 Hypertext Transfer Protocol</a> (上面)。</p><p>&nbsp;&nbsp;a. <a href="http://www.w3.org/Protocols/HTTP/1.0/spec.html#Code301" target="_blank">301 Moved Permanently</a></p><blockquote><p>The requested resource has been assigned a new permanent URL and any future references to this resource should be done using that URL. Clients with link editing capabilities should automatically relink references to the Request-URI to the new reference returned by the server, where possible.<br /> The new URL must be given by the Location field in the response. Unless it was a HEAD request, the Entity-Body of the response should contain a short note with a hyperlink to the new URL.</p><p>If the 301 status code is received in response to a request using the POST method, the user agent must not automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.</p></blockquote><p>&nbsp;&nbsp;b. <a href="http://www.w3.org/Protocols/HTTP/1.0/spec.html#Code301" target="_blank">302 Moved Temporarily</a></p><blockquote><p>The requested resource resides temporarily under a different URL. Since the redirection may be altered on occasion, the client should continue to use the Request-URI for future requests.<br /> The URL must be given by the Location field in the response. Unless it was a HEAD request, the Entity-Body of the response should contain a short note with a hyperlink to the new URI(s).</p><p>If the 302 status code is received in response to a request using the POST method, the user agent must not automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.</p></blockquote><p>Ref:  //  其實只有參考第一個, 複製了它的解釋, 其它篇是覺得寫得不錯, 值得收藏一下^^<br /> 01. <a href="http://www.workingwith.me.uk/articles/scripting/mod_rewrite" target="_blank">mod_rewrite, a beginner's guide (with examples)</a><br /> 02. <a href="http://www.ragepank.com/tags/301-redirect/" target="_blank">301-redirect</a><br /> 03. <a href="http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html" target="_blank">Apache mod_rewrite</a><br /> 04. <a href="http://www.timmguru.com/2006/08/seo-tips-mod-rewrite-non-www-to-www.html" target="_blank">SEO Tips - Mod Rewrite Non-WWW to WWW</a><br /> 05. <a href="http://theseoblogger.com/seo-links/seo-url-tip-www-and-non-www/" target="_blank">Using Mod-rewrite to Redirect Non-www URL to www URL</a><br /> 06. <a href="http://www.redfinsolutions.com/redfin-blog/improve-your-seo-redirecting-non-www-traffic-www" target="_blank">Improve Your SEO By Redirecting Non-WWW Traffic to WWW</a><br /> 07. <a href="http://divspace.com/seo/redirect-visitors-from-non-www-to-www-version-of-your-website-with-htaccess-mod-rewrite/" target="_blank">Redirect Visitors From Non-WWW To WWW Version Of Your Website With .htaccess And mod_rewrite</a></p> ]]></content:encoded> <wfw:commentRss>http://who-know.com/301-redirect-from-non-www-to-www-by-htaccess/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> </channel> </rss>