Azure 上的 Symfony 3.2 项目

Symfony 3.2 Project on Azure

我在为 Azure 上的 symfony 项目设置 web.config 文件时遇到困难。我按照 Deoploying to MS Azure 中的步骤操作,但无法访问 app-name.azurewebsites.net 提供的内容以外的任何内容。所以如果我尝试访问 app-name.azurewebsites.net/admin 我会得到

The resource you are looking for has been removed, had its name changed, or is temporarily unavailable

清除缓存没有解决问题。

web.config:

<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <clear />
        <rule name="BlockAccessToPublic" patternSyntax="Wildcard" stopProcessing="true">
          <match url="*" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{URL}" pattern="/web/*" />
          </conditions>
          <action type="CustomResponse" statusCode="403" statusReason="Forbidden: Access is denied." statusDescription="You do not have permission to view this directory or page using the credentials that you supplied." />
        </rule>
        <rule name="RewriteAssetsToPublic" stopProcessing="true">
          <match url="^(.*)(\.css|\.js|\.jpg|\.png|\.gif)$" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
          </conditions>
          <action type="Rewrite" url="web/{R:0}" />
        </rule>
        <rule name="RewriteRequestsToPublic" stopProcessing="true">
          <match url="^(.*)$" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
          </conditions>
          <action type="Rewrite" url="web/app.php/{R:0}" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

对此进行更新。 我可以到达其他路线的唯一方法是在 url 中设置 app.php。例如:app-name.azurewebsites.net/app.php/admin。当前配置重写有什么问题所以我可以将其设置为 app-name.azurewebsites.net/admin 非常感谢任何解决此问题的指导。

无需创建 web.config 文件来实现此目的,您可以在 应用程序设置 [=59] 中将 web/app.php 添加到 默认文档 =] 通过 Azure 门户。

为此,您可以按照以下步骤操作。

  1. 转到 Azure portal 并导航到您的应用服务。
  2. 单击应用程序设置,然后滚动到默认文档部分。
  3. web/app.php 添加到 默认文档 并单击 保存 按钮。

这里是图片:


编辑:

这是我的文件夹结构:

一旦配置了默认文档,我们就不再需要在URL.

中附加web/app.php


我已经测试了您提供的 web.config 文件,它工作正常。