部署https(ssl)后设置301跳转将http跳转到https
封面图
•
2023-07-14
•
APACHE
483
0
0
0
1.将http请求的80端口设置为重定向到https的443端口,该操作通常由web服务器完成,如Apache、Nginx,操作步骤如下: (1)配置Apache或Nginx服务器,将http请求重定向到https (2)Nginx配置: ``` server { listen 80; server_name example.com; return 301 https://example.com$request_uri; } ``` (3)Apache配置: ``` <VirtualHost *:80> ServerName example.com Redirect / https://example.com/ </VirtualHost> ``` 2.使用.htaccess文件将http请求重定向到https,操作步骤如下: (1)打开.htaccess文件,编辑.htaccess文件 (2)添加以下代码,用来将http请求重定向到https ``` RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} ``` (3)保存.htaccess文件
上一篇:
APACHE如何里一个站点绑定多个域名?用ServerAlias
下一篇:
apache access日志 [22/Jun/2023:16:10:52 +0800] "\n" 400 226
标题录入,一次不能超过6条
返回顶部
留言
留言
评论