﻿<?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>奋斗足迹&#124;崔玉松 &#187; Nginx</title>
	<atom:link href="http://fendou.org/tag/nginx/feed/" rel="self" type="application/rss+xml" />
	<link>http://fendou.org</link>
	<description>为家人，为自己，为生活~~</description>
	<lastBuildDate>Fri, 24 Feb 2012 15:21:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>wordpress的nginx rewrite规则</title>
		<link>http://fendou.org/2009/10/29/wordpress-nginx-rewrite/</link>
		<comments>http://fendou.org/2009/10/29/wordpress-nginx-rewrite/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 02:24:29 +0000</pubDate>
		<dc:creator>崔玉松</dc:creator>
				<category><![CDATA[Operating System]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://fendou.org/?p=605</guid>
		<description><![CDATA[由于godaddy不稳定和龟速，终于把博客搬到自己的VPS上，并且换了一套皮 ，最近日子过得比较快，可能因为事情比较多的缘故，最近两个月写的代码，超过我过去半年的写的代码的总和 废话少说，直接上wordpress Nginx的rewrite规则，我的博客版本是2.8.5，一切正常，其他的不敢保证 if (-d $request_filename){ rewrite ^/(.*)([^/])$ $1$2/ permanent; } if (-f $request_filename/index.html){ rewrite (.*) $1/index.html break; } if (-f $request_filename/index.php){ rewrite (.*) $1/index.php; } if (!-f $request_filename){ rewrite (.*) /index.php; } 第一条在很多Nginx主机上是默认就可以进行301 move的，意思是：如果请求的是目录，那么将请求rewrite到这个目录里面，不加这一条可能会导致二级或者三级目录无法访问，比如请求地址是http://www.abc.com/abc, abc是一个目录，abc中有一个index.html页面，还有一个名为style的目录，index.html 引用style中的css,js等文件，并且引用方式为相对地址，类似这样的结构：&#60;script type=“text/javascript” src=”style/lib/jquery.js“&#62;&#60;/script&#62;，那么除index.html能被请求到之外，index.html中引用的所有文件的请求，都将是404 后面三条网上到处都是，如果你不是跟我一样，在Web根目录下放一些jquery，mysql之类的手册，后面三条就足够使用。包括你使用伪静态化<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F10%2F23%2Fdedecms-nginx-rewrite%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F10%2F29%2Fwordpress-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">DedeCMS 5.6版本的Nginx环境伪静态化</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F09%2F23%2Fsupervisor-nginx-tornado%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F10%2F29%2Fwordpress-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">使用supervisor和nginx发布tornado程序</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F01%2F18%2Fprogramming-language-baseline%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F10%2F29%2Fwordpress-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">程序语言评估标准</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F11%2F01%2Foop%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F10%2F29%2Fwordpress-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">面向对象设计的启发规则</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2007%2F11%2F02%2Fwordpress-%25E8%25AF%258D%25E6%25B1%2587%25E8%25A1%25A8%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F10%2F29%2Fwordpress-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">WordPress 词汇表</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>由于godaddy不稳定和龟速，终于把博客搬到自己的VPS上，并且换了一套皮 <img src='http://fendou.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ，最近日子过得比较快，可能因为事情比较多的缘故，最近两个月写的代码，超过我过去半年的写的代码的总和 <img src='http://fendou.org/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /><br />
废话少说，直接上wordpress Nginx的rewrite规则，我的博客版本是2.8.5，一切正常，其他的不敢保证</p>
<blockquote><p>if (-d $request_filename){<br />
rewrite ^/(.*)([^/])$ $1$2/ permanent;<br />
}<br />
if (-f $request_filename/index.html){<br />
rewrite (.*) $1/index.html break;<br />
}<br />
if (-f $request_filename/index.php){<br />
rewrite (.*) $1/index.php;<br />
}<br />
if (!-f $request_filename){<br />
rewrite (.*) /index.php;<br />
}</p></blockquote>
<p>第一条在很多Nginx主机上是默认就可以进行301 move的，意思是：如果请求的是目录，那么将请求rewrite到这个目录里面，不加这一条可能会导致二级或者三级目录无法访问，比如请求地址是http://www.abc.com/abc, abc是一个目录，abc中有一个index.html页面，还有一个名为style的目录，index.html 引用style中的css,js等文件，并且引用方式为相对地址，类似这样的结构：&lt;<span>script</span><span> type</span>=<span>“text/javascript” </span><span>src</span><span>=”</span><a href="view-source:http://fendou.org/jquery/style/lib/jquery.js">style/lib/jquery.js</a><span>“</span>&gt;&lt;/<span>script</span>&gt;，那么除index.html能被请求到之外，index.html中引用的所有文件的请求，都将是404</p>
<p>后面三条网上到处都是，如果你不是跟我一样，在Web根目录下放一些jquery，mysql之类的手册，后面三条就足够使用。包括你使用伪静态化</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F10%2F23%2Fdedecms-nginx-rewrite%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F10%2F29%2Fwordpress-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">DedeCMS 5.6版本的Nginx环境伪静态化</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F09%2F23%2Fsupervisor-nginx-tornado%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F10%2F29%2Fwordpress-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">使用supervisor和nginx发布tornado程序</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F01%2F18%2Fprogramming-language-baseline%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F10%2F29%2Fwordpress-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">程序语言评估标准</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F11%2F01%2Foop%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F10%2F29%2Fwordpress-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">面向对象设计的启发规则</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2007%2F11%2F02%2Fwordpress-%25E8%25AF%258D%25E6%25B1%2587%25E8%25A1%25A8%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F10%2F29%2Fwordpress-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">WordPress 词汇表</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://fendou.org/2009/10/29/wordpress-nginx-rewrite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

