首页 文章

使用Laravel项目的Azure Web App错误404

提问于
浏览
1

我有一个在Laravel编码的项目,在localhost上工作得很好 .

我从git存储库上传它在Azure上 . 当我尝试访问页面时,我收到以下消息:

“您要查找的资源已被删除,名称已更改,或暂时无法使用 . ”

我已经用谷歌搜索了我遇到的问题,但似乎没有任何效果 .

编辑:

我的Azure WebApp设置为访问site \ wwwroot \ public \作为应用程序 .

Click here to see the picture showing what I said above

4 回答

  • 1

    由于我没有尝试过,我删除了Azure上的应用程序并创建了另一个应用程序 . 这次,它奏效了 . 我不知道为什么 . 可能我的旧文件在某处被破坏了......我不知道 .

  • 0

    可以通过将web.config文件放在公用文件夹中来解决此问题 .

    https://github.com/Azure-Samples/laravel-tasks/blob/master/public/web.config

    <configuration>
      <system.webServer>
        <rewrite>
          <rules>
            <rule name="Imported Rule 1" stopProcessing="true">
              <match url="^(.*)/$" ignoreCase="false" />
              <conditions>
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
              </conditions>
              <action type="Redirect" redirectType="Permanent" url="/{R:1}" />
            </rule>
            <rule name="Imported Rule 2" stopProcessing="true">
              <match url="^" ignoreCase="false" />
              <conditions>
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
              </conditions>
              <action type="Rewrite" url="index.php" />
            </rule>
          </rules>
        </rewrite>
      </system.webServer>
    </configuration>
    

    有关整个过程的更多详细信息:https://docs.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-php-mysql

  • 0

    该错误表明您要查找的文件不在服务器上,或者您没有正确配置web.config文件 .

    如果您使用任何特殊文件名,我建议您通过FTP查看该文件存在于服务器上 .

    我建议你enable diagnostic logging for Web Apps获取详细的错误消息和日志 .

    另外,请检查它是部署还是运行时问题,如下所述:https://github.com/projectkudu/kudu/wiki/Deployment-vs-runtime-issues

  • 1

    由于Laravel使用 \public 作为入口点并且Azure Web App无法识别 .htaccess 文件,您是否可以尝试通过Azure portal将虚拟目录设置为 Application settings

    enter image description here

相关问题