【问题标题】:http Redirect an azure web applicationhttp 重定向一个 azure Web 应用程序
【发布时间】:2023-09-15 09:13:01
【问题描述】:

我的公司有一个运行 tomcat 9.0 的 azure linux Web 应用程序。

我需要设置一个 http 307 重定向来直接使用另一个网站(不是托管在 azure 上)。

我看到了这篇关于如何在网络应用上进行重定向的文章: https://michelebusta.com/azure-tip-just-a-web-app-with-redirect-please-a045d1072659

但我认为这篇文章仅适用于 Windows 实例。

您如何在 linux 中运行的网络应用程序上实现这一点?

【问题讨论】:

    标签: linux azure-web-app-service tomcat9


    【解决方案1】:

    要在 Apache Linux Web App 上完成 URL 重写,您可以按照以下过程。

    1. 在您网站的 /home/site/wwwroot/ 中创建一个 htaccess 文件。
    2. 使用mod_rewrite module 制定类似的规则,如下所示。下面的例子是rewriting URLs from HTTP to HTTPS

      • 重写引擎开启
      • RewriteCond %{HTTP:X-ARR-SSL} ^$
      • RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    【讨论】: