zoukankan      html  css  js  c++  java
  • IIS配置ThinkPHP重写

    IIS10+ThinkPHP6:

    根目录public下新建web.config

     1 <?xml version="1.0" encoding="UTF-8"?>
     2 
     3 <configuration>
     4 <location path="." inheritInChildApplications="false">
     5     <system.webServer>
     6         <rewrite>
     7             <rules>
     8                 <rule name="OrgPage" stopProcessing="true">
     9                     <match url="^(.*)$" />
    10                     <conditions logicalGrouping="MatchAll">
    11                         <add input="{HTTP_HOST}" pattern="^(.*)$" />
    12                         <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    13                         <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    14                     </conditions>
    15                     <action type="Rewrite" url="index.php/{R:1}" />
    16                 </rule>
    17             </rules>
    18         </rewrite>
    19     </system.webServer>
    20     </location>
    21 
    22 </configuration>
    <location path="." inheritInChildApplications="false"></location>
    标签在根目录解除子目录的继承,若没有虚拟目录只部署在根目录,则删除标签(只删第4、第20行)。

    虚拟目录webconfig的配置

    虚拟目录webconfig不变,用网上抄的。

    另网上有另外解决:

    2.在子目录对冲突的节点处理

    根目录节点

    1 <connectionStrings>
    2     <add name="DBConnectionString" connectionString="Data Source=.;Initial Catalog=test;User ID=sa;Password=sa123" providerName="System.Data.SqlClient"/>
    3   </connectionStrings>

    子目录节点

    1 <connectionStrings>
    2     <clear/>
    3     <add name="DBConnectionString" connectionString="Data Source=.;Initial Catalog=test;User ID=sa;Password=sa123" providerName="System.Data.SqlClient"/>
    4   </connectionStrings>

    在冲突的节点前先clear,清除之前的配置,然后再加载下面的配置就可以了,除了clear 还有remove也可以

     <connectionStrings>
        <remove name="DBConnectionString"/>
        <add name="DBConnectionString" connectionString="Data Source=.;Initial Catalog=test;User ID=sa;Password=sa123" providerName="System.Data.SqlClient"/>
      </connectionStrings>

    这种配置方法可以用在所有的节点上,使用起来也比较灵活

  • 相关阅读:
    Windows的全新文件系统:ReFS
    Eclipse Virgo 3.0发布了
    Web Sites and a Plugin Free Web
    PhoneGap现已完全支持WP7
    深入探索PowerPivot客户端和服务器端架构
    Funf,一个传感和数据处理的移动框架
    利用Contained Database和DAC来开发基于SQL Server "Denali"和SQL Azure之上的应用程序
    一个漂亮的HTML5后台管理界面模板
    笔试题收集
    笔试面试的准备工作
  • 原文地址:https://www.cnblogs.com/xwhgr/p/15292343.html
Copyright © 2011-2022 走看看