<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[Snooda]]></title> 
<link>http://www.snooda.com/index</link> 
<description><![CDATA[Snooda's Blog]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[Snooda]]></copyright>
<item>
<link>http://www.snooda.com/read/105</link>
<title><![CDATA[nginx下使用CodeIgniter框架完全屏蔽url中index.php的方法]]></title> 
<author>snooda &lt;admin@snooda.com&gt;</author>
<category><![CDATA[默认分类]]></category>
<pubDate>Sun, 27 Jun 2010 08:23:20 +0000</pubDate> 
<guid>http://www.snooda.com/read/105</guid> 
<description>
<![CDATA[ 
	    CodeIgniter默认url中是带有“index.php”这个字段的，不好看，不利于SEO，很多人想去掉它。网上和官方也有很多方法，大多是rewrite一下了事，这些方法的通病就是可以去掉&quot;index.php&quot;字段，但是加上后仍然能访问，甚至“http://****.com/index.php/index.php/index.php&quot;这种url也照常可以访问，无形中给网站带来了安全隐患。并且在隐藏网站所用脚本语言的时候也不利，通过测试加上index.php后是否可以访问可以很轻易的探测出网站是否由php开发，是否使用了CI框架。为了以上安全性考虑，需要完全去掉index.php，即：加上后返回404页面。<br />
<br />
<br />
    查询了网上的资料，发现没有相关内容，阅读了一下CI的源码，发现不是CI的问题，而是web服务器导致的此问题。<br />
<br />
课外小知识：对于/index.php/abc这种url，Apache和lighttpd会按&quot;index.php?abc&quot;来解释，而nginx会认为是请求名字是“index.php”的目录下的abc文件的内容。所以CI在nginx下不配置rewrite是无法运行的，而在Apache和lighttpd则正常。<br />
<br />
课外小知识二：nginx里rewrite ^/(.*)$ /index.php?$1 last;来rewrite请求时，对于：/abc.abc这类请求，会rewrite成“index.php/abc_abc”,即会把“点”变成“下划线”，不清楚是为了什么。<br />
<br />
课外小知识三：nginx配置文件里的rewrite规则不是只执行一次就完事的，是“执行一遍，假如没有碰到break，就按rewrite后的新路径再执行一遍，直到不再变化或者遇到break或者执行满10次报500错误退出”，所以单纯的用小知识二里的重写规则是不行的，需要在后面加上一句break，这样重写一遍后就不再执行了。<br />
<br />
    由上可得：在nginx配置文件里：<br />
    rewrite ^/(.*)$ /index.php?$1 last;<br />
    break;<br />
    即可完全屏蔽index.php访问。
]]>
</description>
</item><item>
<link>http://www.snooda.com/read/105#blogcomment81</link>
<title><![CDATA[[评论] nginx下使用CodeIgniter框架完全屏蔽url中index.php的方法]]></title> 
<author>Anoymous &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 31 Mar 2011 06:33:04 +0000</pubDate> 
<guid>http://www.snooda.com/read/105#blogcomment81</guid> 
<description>
<![CDATA[ 
	nnnnnn
]]>
</description>
</item>
</channel>
</rss>