文件或文件夹存在,但在IIS Web服务器中抛出404

问题描述 投票:0回答:1

我用F3框架构建了一个Web应用程序。在我的本地(XAMPP),一切都很顺利。但是,在我将其上传到服务器(IIS Web服务器)后,出现消息404 - “文件或文件夹不存在”。我很困惑,是什么原因导致这个问题。

注意 :

  • 我在IIS中创建新站点,根文件夹指向“D:/ www / my-project”。
  • 默认根文件夹是“C:/ inetpub / wwwroot”。
  • 有一个域指向ip服务器。
  • 当我访问域时,会出现第一页。但在切换页面/路由后,下一页将抛出404。
php iis-8 fat-free-framework
1个回答
1
投票

在根目录下创建web.config文件并将代码放在下面(此配置可能因您的应用程序结构而异)

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Application" stopProcessing="true">
          <match url=".*" ignoreCase="false" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
          </conditions>
          <action type="Rewrite" url="index.php" appendQueryString="true" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>
© www.soinside.com 2019 - 2024. All rights reserved.