2017-02-20 78 views
0

我的根web.config文件中有规则强制结尾斜线并将所有URL重写为索引文件,作为Codeigniter设置的一部分。这一切似乎工作除了在主页上,服务器(而不是Codeigniter)引发404错误。web.config重写不适用于主页

奇怪的是,它只在现场的网站上这样做,它在我的本地设置(这与现场的设置相同)上工作正常。

我的web.config文件与索引文件一起位于根目录下,并且包含以下规则;

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
<system.webServer> 
    <rewrite> 
     <rules> 
      <rule name="Force trailing slash" 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="Redirect" url="{R:1}/" redirectType="Permanent" /> 
      </rule> 
      <rule name="Remove index file" stopProcessing="true"> 
       <match url="(.*)$" /> 
       <conditions logicalGrouping="MatchAll"> 
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
        <add input="{REQUEST_URI}" pattern="^/$" negate="true" /> 
       </conditions> 
       <action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" /> 
      </rule> 
     </rules> 
    </rewrite> 
</system.webServer> 

我怎么能确定是什么原因造成这种直播网站上,或者是有只是我需要在我重写规则的改变?

回答

0

试试这个对我有用!

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <system.webServer> 
    <rewrite> 
     <rules> 
     <rule name="Imported Rule 1" stopProcessing="true"> 
      <match url="^(.*)$" ignoreCase="false" /> 
      <conditions logicalGrouping="MatchAll"> 
       <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
       <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
      </conditions> 
      <action type="Rewrite" url="index.php?url={R:1}" appendQueryString="true" /> 
      </rule> 
     </rules> 
    </rewrite> 
    </system.webServer> 
</configuration>