2017-02-20 42 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> 
相關問題