<?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; mod_rewrite</title>
	<atom:link href="http://www.weijingtai.com/tag/mod_rewrite/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.weijingtai.com</link>
	<description>Url rewrite 伪静态规则使用收集</description>
	<lastBuildDate>Mon, 14 Jun 2010 03:30:32 +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>mod_rewrite的介绍</title>
		<link>http://www.weijingtai.com/2009/04/08/mod_rewrite/</link>
		<comments>http://www.weijingtai.com/2009/04/08/mod_rewrite/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 07:09:01 +0000</pubDate>
		<dc:creator>衣不如新</dc:creator>
				<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[htaccess]]></category>

		<guid isPermaLink="false">http://www.weijingtai.com/?p=23</guid>
		<description><![CDATA[mod_rewrite是apache的一个功能模块，基于lamp架构的空间伪静态大多用mod_rewrite来实现网站的伪静态。伪静态规则文件保存为.htaccess并存放于网站目录即可]]></description>
			<content:encoded><![CDATA[<p><strong>什么叫做伪静态mod_rewrite</strong></p>
<p>mod_rewrite是apache的一个功能模块，基于lamp架构的空间伪静态大多用mod_rewrite来实现网站的伪静态。伪静态规则文件保存为.htaccess并存放于网站目录即可。<br />
以下是关于mod_rewrite的一些知识简介：</p>
<p><span id="more-23"></span></p>
<p>首先要开启apache的mod_rewrite功能。<br />
在apache目录的apacheconf 这个文件夹下的httpd.conf文件用记事本打开编辑，找到如下一句：<br />
#LoadModule rewrite_module modules/mod_rewrite.so<br />
将前面的#号去掉，变成：<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
然后再在同一文件找到下面一句：<br />
AllowOverride None<br />
将其改为：<br />
AllowOverride All<br />
然后关闭并保存文件。这样一来，Apache的mod_rewrite的功能就被开启，非常简单。<br />
下面，我要用mod_rewrite实现这样的URL：<br />
<a href="http://xxx.com/0725.html">http://xxx.com/0725.html</a><br />
<a href="http://xxx.com/0726.html">http://xxx.com/0726.html</a><br />
<a href="http://xxx.com/0727.html">http://xxx.com/0727.html</a><br />
…<br />
上面链接的意思，就是显示07月25日的历史上发生了什么事情，类似这样。这样看起来就很美观、整齐了,貌似生成html了。然，他们地址实际是：<br />
<a href="http://xxx.com/index.php?today=0725">http://xxx.com/index.php?today=0725</a><br />
<a href="http://xxx.com/index.php?today=0726">http://xxx.com/index.php?today=0726</a><br />
<a href="http://xxx.com/index.php?today=0727">http://xxx.com/index.php?today=0727</a><br />
…<br />
现在我就是要实现把 index.php?today=为静态。以下是代码：<br />
1..htaccess 文件<br />
RewriteEngine On<br />
RewriteBase /<br />
RewriteCond %{REQUEST_FILENAME} !-f<br />
RewriteCond   %{REQUEST_FILENAME} !-d<br />
RewriteRule ^([0-9]+).html$   /index.php?today=$1<br />
粗体字这里我说明一下，其它的按这个格式吧，具体我现在也不理解。<br />
[0-9]的意思是，参数只能是0~9这些数字，如果你要包含任何字符，就改为：<br />
RewriteRule ^(.+).html$ /index.php?today=$1<br />
这里[0-9]改为了. ，这个.就代表任意字符</p>
]]></content:encoded>
			<wfw:commentRss>http://www.weijingtai.com/2009/04/08/mod_rewrite/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

