YGBOOK(基于ThinkPHP开发的)在win系统下的伪静态规则 web.config
    文章作者:恒爱网络 阅读次数:6851 发布时间:2019-6-8

    某用户在我司空间安装 YGBOOK(基于ThinkPHP开发的),由于需要伪静态支持,因此直接用IIS8.5下的 URLRewire 将自带的.htaccess规则转化为 web.config

    但是却发现安装地址 http://www.xxx.com/install 无效,提示太多的重定向。

    奇怪之余,搜索了下该程序,发现大多都推荐 linux或 Nginx 环境,此程序也不自带IIS下的伪静态规则。

    许久之后才发现 直接转化过来的web.config 规则由于没有隐藏index.php ,所以导致了重定向问题的出现。

    如果强制还原数据库的方式安装后,测试也会发现 YGBOOK 伪静态无效,怎么点击都只显示首页。

    正确的web.config 伪静态代码如下:

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <defaultDocument>
                <files>
                    <add value="index.php" />
                </files>
    
            </defaultDocument>
             <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>
    
        </system.webServer>
    
    
    </configuration>