全站https后出现http无法自动跳转https,甚至出现404错误的解决方法。
我们采用nginx的rewrite方法,使用nginx最新支持的写法,下面配置将实现将所有的http请求通过rewrite重写到https上;打开文件 /usr/local/nginx/conf/vhost/www.***.com.conf 文件,在如下server { } 代码块中添加两空行之间的代码:
server {
listen 80;
server_name www.gyhqq.com;
index index.html index.php index.htm;
return 301 https://$server_name$request_uri; #这是nginx最新支持的写法(复制粘贴到即可)
access_log /usr/local/nginx/logs/8080-access.log main;
error_log /usr/local/nginx/logs/8080-error.log;
location ~ / {
root /var/www/html/8080;
index index.html index.php index.htm;
}
}
另附上LNMP网站环境的搭建教程
参考我的另一篇文章:Linux服务器搭建网站环境(PHP网站环境、JAVA网站环境)

资源分享QQ群
本站是一个IT技术分享社区, 会经常分享资源和教程; 分享的时代, 请别再沉默!
2019年5月2日 下午5:00 1F
很有用!
2019年5月2日 下午5:49 2F
采用了
2019年6月17日 上午12:41 B1
@ main 好用就好