<?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>WordPress后援基地 &#187; Hack</title>
	<atom:link href="http://www.wpservice.org/tag/hack/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.wpservice.org</link>
	<description>WP强有力支持</description>
	<lastBuildDate>Tue, 07 Apr 2009 13:12:00 +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 .htaccess 的10个Hack技巧</title>
		<link>http://www.wpservice.org/2009/04/07/wordpress-htaccess-skills-of-10-hack/</link>
		<comments>http://www.wpservice.org/2009/04/07/wordpress-htaccess-skills-of-10-hack/#comments</comments>
		<pubDate>Tue, 07 Apr 2009 13:12:00 +0000</pubDate>
		<dc:creator>老薛</dc:creator>
				<category><![CDATA[使用技巧]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[Hack]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[技巧]]></category>

		<guid isPermaLink="false">http://www.wpservice.org/?p=40</guid>
		<description><![CDATA[注意：以下文章翻译来自英文网站：10 awesome .htaccess hacks for WordPress
.htaccess文件是用来控制Apache服务器的，它很有用，并允许你做很多事，下面就介绍关于.htaccess的10个修改方法，让你的wordpress更加的安全、多功能、和可用性！
警告：在修改之前请你备份.htaccess，一边修改后出现错误你可以恢复！
 1.重定向你的WordPress RSS feeds 到feedburner或feedsky

# temp redirect wordpress content feeds to feedburner
&#60;IfModule mod_rewrite.c&#62;
 RewriteEngine on
 RewriteCond %{HTTP_USER_AGENT} !FeedBurner    [NC]
 RewriteCond %{HTTP_USER_AGENT} !FeedValidator [NC]
 RewriteRule ^feed/?([_0-9a-z-]+)?/?$ http://在feedburner你的地址 [R=302,NC,L]
&#60;/IfModule&#62;

2.删除博客中的/category/你是不是觉得博客分类浏览url老有个/category/觉得很不滑爽？要移除/category/，除了可以用插件Top Level Categories来实现，也可以通过修改.htaccess来实现！
打开.htaccess，在里边添加：一般是紧跟在最后一行RewriteRule ^字样的下面添加

RewriteRule ^category/(.+)$ http://www.yourblog.com/$1 [R=301,L]

注意：记得要把http://www.yourblog.com/替换为你的网址
3.使用浏览器的缓存
强制浏览器使用缓存，加速网页载入时间，当然是在网页没有改变的前提下

FileETag MTime Size
&#60;ifmodule mod_expires.c&#62;
  &#60;filesmatch "\.(jpg&#124;gif&#124;png&#124;css&#124;js)$"&#62;
       ExpiresActive on
 [...]]]></description>
			<content:encoded><![CDATA[<p>注意：以下文章翻译来自英文网站：<a href="http://www.catswhocode.com/blog/10-awesome-htaccess-hacks-for-wordpress">10 awesome .htaccess hacks for WordPress</a><br />
.htaccess文件是用来控制Apache服务器的，它很有用，并允许你做很多事，下面就介绍关于.htaccess的10个修改方法，让你的wordpress更加的安全、多功能、和可用性！<br />
<strong>警告：在修改之前请你备份.htaccess，一边修改后出现错误你可以恢复！</strong><br />
<span id="more-40"></span> <strong>1.重定向你的WordPress RSS feeds 到feedburner或feedsky</strong></p>
<blockquote>
<pre class="html" style="font-family: monospace;"># temp redirect wordpress content feeds to feedburner
&lt;IfModule mod_rewrite.c&gt;
 RewriteEngine on
 RewriteCond %{HTTP_USER_AGENT} !FeedBurner    [NC]
 RewriteCond %{HTTP_USER_AGENT} !FeedValidator [NC]
 RewriteRule ^feed/?([_0-9a-z-]+)?/?$ http://在feedburner你的地址 [R=302,NC,L]
&lt;/IfModule&gt;</pre>
</blockquote>
<p><strong>2.删除博客中的/category/</strong>你是不是觉得博客分类浏览url老有个/category/觉得很不滑爽？要移除/category/，除了可以用插件<a href="http://fortes.com/projects/wordpress/top-level-cats/">Top Level Categories</a>来实现，也可以通过修改.htaccess来实现！<br />
打开.htaccess，在里边添加：一般是紧跟在最后一行<strong>RewriteRule ^</strong>字样的下面添加</p>
<blockquote>
<pre class="html" style="font-family: monospace;">RewriteRule ^category/(.+)$ http://www.yourblog.com/$1 [R=301,L]</pre>
</blockquote>
<p><strong>注意：</strong>记得要把http://www.yourblog.com/替换为你的网址<br />
<strong>3.使用浏览器的缓存</strong><br />
强制浏览器使用缓存，加速网页载入时间，当然是在网页没有改变的前提下</p>
<blockquote>
<pre class="html" style="font-family: monospace;">FileETag MTime Size
&lt;ifmodule mod_expires.c&gt;
  &lt;filesmatch "\.(jpg|gif|png|css|js)$"&gt;
       ExpiresActive on
       ExpiresDefault "access plus 1 year"
   &lt;/filesmatch&gt;
&lt;/ifmodule&gt;</pre>
</blockquote>
<p><strong>4.压缩静态数据</strong><br />
此代码肯定会节省您（和您的访客）带宽</p>
<blockquote>
<pre class="html" style="font-family: monospace;">AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html</pre>
</blockquote>
<p><strong>5.重定向”day”和”name”到/%postname%/</strong><br />
如果你使用的固定链接为”/%year%/%monthnum%/%day%/%postname%/”,你又想把固定链接设置为”/%postname%/”,又怕以前的链接失效，那这个可以帮助你解决！<br />
首先把你的固定链接设置成/%postname%/，然后在你的.htaccess添加：</p>
<blockquote>
<pre class="html" style="font-family: monospace;">RedirectMatch 301 /([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ http://www.domain.com/$4</pre>
</blockquote>
<p>记得把www.domain.com替换成你的域名！<br />
<strong>6.如果拒绝带网页链接评论</strong><br />
这个功能你可以使用akismet插件来完成，当然也可以通过修改.htaccess来完成！</p>
<blockquote>
<pre class="html" style="font-family: monospace;">RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} .wp-comments-post\.php*
RewriteCond %{HTTP_REFERER} !.*yourblog.com.* [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]</pre>
</blockquote>
<p>记得把yourblog.com替换成你的域名！<br />
<strong>7.如何重定向访问者到一个固定页面</strong><br />
有些时候你的博客要维护，你想把你的博客的访问者重定向到一个维护的说明页面，这个就能然你实现！</p>
<blockquote>
<pre class="html" style="font-family: monospace;">RewriteEngine on
RewriteCond %{REQUEST_URI} !/maintenance.html$
RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123
RewriteRule $ /maintenance.html [R=302,L]</pre>
</blockquote>
<p><strong>maintenance.html</strong> 这个就是你要重定向到的页面<br />
<strong>8.拒绝引用你的博客的图片</strong><br />
有些时候由于其他网站引用你博客的图片使得你的流量暴增，这个功能将是别人无法引用你的图片！</p>
<blockquote>
<pre class="html" style="font-family: monospace;">RewriteEngine On
#Replace ?mysite\.com/ with your blog url
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
#Replace /images/nohotlink.jpg with your "don't hotlink" image url
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpg [L]</pre>
</blockquote>
<p>记得把mysite.com修改成你的域名，nohotlink.jpg 为别人引用你图片时在他网站出现的图片！<br />
<strong>9.只允许你自己的Ip地址才可以登录到wp-admin管理后台</strong><br />
其实这个也很有用，只是我们这些使用ADSL的无法拥有固定Ip，所以这个功能就有点无奈！</p>
<blockquote>
<pre class="html" style="font-family: monospace;">AuthUserFile /dev/null
AuthGroupFile /dev/null
AuthName "Example Access Control"
AuthType Basic
&lt;LIMIT GET&gt;
order deny,allow
deny from all
allow from xx.xx.xx.xx
&lt;/LIMIT&gt;</pre>
</blockquote>
<p>xx.xx.xx.xx为你的IP地址！<br />
<strong>10.禁止指定的IP地址访问</strong><br />
有些时候你的博客可能受到同一个Ip地址的骚扰，比如说垃圾短信，你可以用禁止此IP访问的办法来抵制！</p>
<blockquote>
<pre class="html" style="font-family: monospace;">&lt;Limit GET POST&gt;
order allow,deny
deny from 200.49.176.139
allow from all
&lt;/Limit&gt;</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.wpservice.org/2009/04/07/wordpress-htaccess-skills-of-10-hack/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
