|  | 
 
| 本帖最后由 qfish 于 2011-5-29 13:27 编辑 
 论坛里有很多关于去掉index.php的教程和代码,但是悲剧的是都是自己能配置服务器,
 并且服务器要么是 Apache,就是IIS 6- 。。。
 没有IIS7.5下是如何配置的。
 
 我想大家应该有很多都是用的服务商提供的空间,有些文件是没法修改的。
 有一次在群里看到一个人吵着服务商垃圾,不让他修改httpd.conf文件,
 说什么你让我改我就能伪静态了
  ...还说服务器垃圾,不支持URL Rwrite。 
 其实IIS7.5是支持的,并且可配置程度及灵活性是相当高的,
 只要web.config的规则配置你懂得,其实你是可以完全无视服务商的
  ,这个你懂得... 什么404,500etc. 过滤文件,限制访问之类的都不算个事。
 
 从这个角度来看,很多人由于对Web.config的不了解,以及对所看到的教程的盲目崇拜,才会闹出上面那样的尴尬。
 
 不说了,直接上代码:
 web.config
 
 如果只是需要去掉index.php, 那直接把下面这段代码加到 <system.webServer> </system.webServer>中间就可以了。XML复制代码 复制代码 <?xml version="1.0" encoding="UTF-8"?>
 <configuration>
 <system.webServer>
 <directoryBrowse enabled="false" />
 <rewrite>
 <rules>
 <rule name="OrgPage" stopProcessing="true">
 <match url="^(.*)$" />
 <conditions logicalGrouping="MatchAll">
 <add input="{HTTP_HOST}" pattern="^(.*)$" />
 <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
 <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
 </conditions>
 <action type="Rewrite" url="index.php/{R:1}" />
 </rule>
 </rules>
 </rewrite>
 <defaultDocument>
 <files>
 <clear />
 <add value="index.asp" />
 <add value="index.aspx" />
 <add value="index.php" />
 <add value="index.html" />
 <add value="Default.htm" />
 <add value="Default.asp" />
 <add value="index.htm" />
 <add value="Default.aspx" />
 <add value="index.shtml" />
 </files>
 </defaultDocument>
 <httpErrors>
 <error statusCode="500" subStatusCode="1" prefixLanguageFilePath="" path="www.QFisH.net"
 responseMode="ExecuteURL" />
 <error statusCode="404" subStatusCode="1" prefixLanguageFilePath="" path="qfish.me" responseMode="Redirect" />
 </httpErrors>
 </system.webServer>
 </configuration>
 
 
 XML复制代码 复制代码 <rewrite>
 <rules>
 <rule name="OrgPage" stopProcessing="true">
 <match url="^(.*)$" />
 <conditions logicalGrouping="MatchAll">
 <add input="{HTTP_HOST}" pattern="^(.*)$" />
 <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
 <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
 </conditions>
 <action type="Rewrite" url="index.php/{R:1}" />
 </rule>
 </rules>
 </rewrite>
 
 
 
 需要注意的是还要修改 设置Codeigniter的config.php文件,该文件默认在application/config目录下。
 这个文件中的下列内容:
 
 PHP复制代码 复制代码 // $config['index_page'] = "index.php"; 把其中的 "index.php" 改成 "" ,如下:
 $config['index_page'] = "";
 
 希望能帮到一些想在IIS7.5下去掉“index.php”的同鞋...跟详细可以看:
 IIS7.5的伪静态URL Rewrite规则(Ci,codeigniter,eMlog,Discuz…)http://qfish.me/2011/05/iis7-5-url-rewrite.htmll
 
 | 
 评分
查看全部评分
 |