thinkcmf5 iis+php重写配置

TP在本机运行非常好,谁想到服务器上后,连http://www.***.com/wap/login/index都404错误了,

中间的郁闷过程不表。

解决方案分两步:

第一步:

下载rewrite_2.0_rtw_x64.msi,在IIS7的服务器上安装,安装后,重启IIS,我是用开始-运行-iisreset重启IIS的,这时再打开IIS,会发现多了一个新的模块:

就是中间这个URL Rewrite,到此,第一步结束了,

有能力的同学可以顶着英文进行操作,自行配置重写规则,

其他同学直接操作第二步。

第二步:

在php网站根目录下新建个web.config文件,内容入下:

 

 
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="WPurls" 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>

 


如果你的网站根目录不是index.php,自行修改,Thinkphp的默认就是这个页面。

 

至此,重启IIS,再次访问http://www.***.com/wap/login/index,顺利打开,大功告成。

posted @ 2017-09-27 09:17  djiz  阅读(407)  评论(0编辑  收藏  举报