apache2 强制跳转https

虽说是面向百度编程 但是自己的情况和别人的还是有点不同 踩了很多坑 也花了不少时间 现在记录一下
在已配置好https的情况下
/etc/apache2/apache2.conf
添加以下代码

<VirtualHost *:80>
    ServerName 你的网址
    ServerAlias 你的网址
    RewriteEngine on
    RewriteRule ^(.*)?$ https://你的网址$1 [R=301,L]
</VirtualHost>

重启apache2service apache2 restart

发布了38 篇原创文章 · 获赞 7 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_35510729/article/details/102516750