【问题标题】:http to https redirect with Apache2 is not working使用 Apache2 的 http 到 https 重定向不起作用
【发布时间】:2017-12-28 13:31:01
【问题描述】:

我目前正在开发一个使用 Apache 托管网站的 AWS 实例。我已经设置了我的 SSL,我可以转到 https://example.com 就好了,但是当我转到 http://example.com 时,我不会被重定向。有了这个,我尝试了以下方法:

  • 在我的 example.com.conf 中,我尝试了 Redirect permenant / https blah blah
  • 也在.conf 中使用了许多重写规则,都声称“这将适用于任何配置”。我也启用了 Apache2 rewrite mod。
  • 我已经运行sudo a2ensite example.com.conf

这是我的 .conf

<VirtualHost *:80>
    ServerName example.com
    ServerAlias example.com *.example.com
    Redirect permanent / https://example.com/
    #RewriteEngine On
    #RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<IfModule mod_ssl.c>
    <VirtualHost _default_:443>
    ... all my site stuff
</IfModule>

我将非常感谢任何可以提供帮助的人。非常感谢。

【问题讨论】:

    标签: ubuntu apache2


    【解决方案1】:

    更改/etc/apache2/apache2.conf => 更改所有AllowOverride 所有,

    并确保/etc/apache2/sites-available/000.default.conf => 验证您访问的目录的路径。

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/floder that you acess /public
    <Directory /var/www/ninja/public>   
    AllowOverride All
    </Directory>     
    
    猜你喜欢
    • 2016-06-14
    • 2014-03-10
    • 2018-06-11
    • 2015-07-28
    • 2023-03-03
    • 2016-12-09
    • 2022-01-14
    • 2021-04-15
    • 2018-01-31
    相关资源
    最近更新 更多