【问题标题】:Redirect After Proxy Apache2代理 Apache2 之后的重定向
【发布时间】:2021-02-22 09:52:46
【问题描述】:

我有一个在 https://ip:8443 上运行的应用程序。我有一个 Apache2 代理服务器,它位于这个应用程序的前面,配置如下。

<VirtualHost *:80>
        ServerName mydomain
        ServerAlias mydomain
        Redirect permanent / https://mydomain/
</VirtualHost>

<VirtualHost *:443>
        ProxyPreserveHost On
        ProxyRequests Off
        SSLProxyEngine On
        ServerName mydomain
        ServerAlias mydomain
        ProxyPass / https://ip:8443/
        ProxyPassReverse / https://ip:8443/
        SSLCertificateFile /etc/letsencrypt/live/mydomain/cert.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/mydomain/privkey.pem
</VirtualHost>

现在,当我在浏览器上点击 https://mydomain 时,它可以正常工作并显示 https://ip:8443 内容。

现在我希望当有人访问 https://mydomain 时被重定向到另一个显示 https:// 的 URL https://mydomain/subfolder ip:8443/子文件夹.

我在这里搜索了一周并尝试了很多解决方案,但都没有奏效。

【问题讨论】:

    标签: apache server proxy webserver


    【解决方案1】:

    这个解决方案对我有用。

    我在&lt;VirtualHost *:443&gt;中添加了以下几行

    <VirtualHost *:443>
            ...
            RewriteEngine On
            RewriteCond %{REQUEST_URI} ^/$
            RewriteRule (.*) https://mydomain/subfolder/ [R=301,L]
    </VirtualHost>
    

    【讨论】:

      猜你喜欢
      • 2015-05-28
      • 1970-01-01
      • 1970-01-01
      • 2022-06-13
      • 2017-01-29
      • 2019-11-04
      • 2016-11-13
      • 2016-11-03
      • 2021-03-11
      相关资源
      最近更新 更多