发布于 2015-06-06 08:10:44 | 229 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的精品教程,程序狗速度看过来!

微软IIS WEB服务器

Internet Information Services(IIS,互联网信息服务),是由微软公司提供的基于运行Microsoft Windows的互联网基本服务。最初是Windows NT版本的可选包,随后内置在Windows 2000、Windows XP Professional和Windows Server 2003一起发行,但在Windows XP Home版本上并没有IIS。


论坛里有很多关于去掉index.php的教程和代码,但是悲剧的是都是自己能配置服务器,
并且服务器要么是 Apache,就是IIS 6- 。。。
没有IIS7.5下是如何配置的。

我想大家应该有很多都是用的服务商提供的空间,有些文件是没法修改的。
有一次在群里看到一个人吵着服务商垃圾,不让他修改httpd.conf文件,
说什么你让我改我就能伪静态了...还说服务器垃圾,不支持URL Rwrite。

其实IIS7.5是支持的,并且可配置程度及灵活性是相当高的,
只要web.config的规则配置你懂得,其实你是可以完全无视服务商的,这个你懂得...
什么404,500etc. 过滤文件,限制访问之类的都不算个事。

从这个角度来看,很多人由于对Web.config的不了解,以及对所看到的教程的盲目崇拜,才会闹出上面那样的尴尬。

不说了,直接上代码:
web.config

 
<?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>

如果只是需要去掉index.php, 那直接把下面这段代码加到 <system.webServer> </system.webServer>中间就可以了。
<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目录下。

这个文件中的下列内容:

 
// $config[‘index_page‘] = "index.php"; 把其中的 "index.php" 改成 "" ,如下:
$config[‘index_page‘] = "";



希望能帮到一些想在IIS7.5下去掉“index.php”的同鞋...跟详细可以看:
IIS7.5的伪静态URL Rewrite规则(Ci,codeigniter,eMlog,Discuz…)http://domain.com/2011/05/iis7-5-url-rewrite.htmll



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务