由于tp是属于伪静态的,所以我们需要安装伪静态模块
下载rewrite_2.0_rtw_x64.msi,在IIS7的服务器上安装,安装后,重启IIS,我是用开始-运行-iisreset重启IIS的,这时再打开IIS,会发现多了一个新的模块:
就是中间这个URL Rewrite
接下来在php网站public目录下新建个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的默认就是这个页面
网上的教程大部分到这里来就结束了,然后你们就会发现总是出现403错误,浏览器找不到对应的资源之类的,我花了一天的时间才找到这个问题所在
因为我们配置指向的目录是public,创建的用户的权限也只有访问public的权限,对于上一层的权限是没有的,所以我们应该给所在的用户升级权限,至于怎么升级,计算机基础操作我就不啰嗦了。
Copyright © 2004-2021 Ynicp.com 版权所有 法律顾问:建纬(昆明)律师事务所 昆明市网翼通科技有限公司 滇ICP备08002592号-4