Ubuntu 使用Apache2的http到https重定向不起作用

Ubuntu 使用Apache2的http到https重定向不起作用,ubuntu,apache2,Ubuntu,Apache2,我目前正在处理一个AWS实例,该实例使用Apache托管一个网站。我已经设置了我的SSL,我可以去的只是罚款,但当我去我没有得到重定向。因此,我尝试了以下方法: 在我的example.com.conf中,我尝试了重定向permenant/https等等 此外,在.conf中还使用了许多重写规则,都声称“这将适用于任何配置”。我还启用了Apache2重写模块 我已经运行了sudoa2ensite example.com.conf 这是我的.conf <VirtualHost *:80&g

我目前正在处理一个AWS实例,该实例使用Apache托管一个网站。我已经设置了我的SSL,我可以去的只是罚款,但当我去我没有得到重定向。因此,我尝试了以下方法:

  • 在我的example.com.conf中,我尝试了重定向permenant/https等等
  • 此外,在.conf中还使用了许多重写规则,都声称“这将适用于任何配置”。我还启用了Apache2重写模块
  • 我已经运行了
    sudoa2ensite 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>

ServerName example.com
ServerAlias example.com*.example.com
重定向永久/https://example.com/
#重新启动发动机
#重写规则^(.*)$https://%{HTTP_HOST}$1[R=301,L]
ErrorLog${APACHE_LOG_DIR}/error.LOG
CustomLog${APACHE\u LOG\u DIR}/access.LOG组合
... 我所有的网站资料

我将非常感谢任何能帮助我的人。非常感谢。

更改
/etc/apache2/apache2.conf
=>更改所有
允许覆盖所有

并确保
/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>     
ServerAdminwebmaster@localhost
您访问的DocumentRoot/var/www/floder/public
允许超越所有