IIS 7.下面URL Rewrite的路由配置

海豚PHP的源码Rewrite配置是针对Linux下面的Apache设置的.htaccess,但是像我使用的是Windows Server IIS 7的用户来说,需要手动设置URL Rewrite的规则,才可以使得前台通过index.php路由访问正常,具体的做法很简单,安装好Rewrite组件后,在网站根目录下新建一个web.config,然后复制以下内容,保存后,前台即可路由正常了
<?xml version="1.0" encoding="UTF-8"?>  
<configuration>  
  <system.webServer>  
    <rewrite>  
      <rules>  
        <rule name="thinkPhp" enabled="true" stopProcessing="true">  
          <match url=".*" />  
          <conditions logicalGrouping="MatchAll">  
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />  
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />  
          </conditions>  
          <action type="Rewrite" url="index.php/{R:0}" />  
        </rule>  
      </rules>  
    </rewrite>  
  </system.webServer>  
</configuration>

0 个评论

要回复文章请先登录注册