===============================================nginx
2019/3/31_第1次修改 ccb_warlock服務器
===============================================優化
搜索引擎SEO優化是指經過一些手段,提升網站的權重(排名)。網站
搜索引擎
spa
前提:設計
1. 以www.abc.cn爲例;code
2. 以nginx做爲反代服務器;server
3. 反代目標地址:192.168.1.1;blog
server { listen 80; server_name www.abc.cn abc.cn; access_log off; error_log off; # 其餘解析省略 location / { rewrite ^(.*)$ https://$host$1 permanent; } } server { listen 443 ssl; server_name www.abc.cn abc.cn; access_log off; error_log off; # ssl配置省略 # 其餘解析省略 location / { proxy_pass http://192.168.1.1; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_http_version 1.1; } }
思路:將abc.cn的解析單獨拿出來。
假設:
server { listen 80; server_name www.abc.cn; access_log off; error_log off; # 其餘解析省略 location / { rewrite ^(.*)$ https://$host$1 permanent; } } server { listen 443 ssl; server_name www.abc.cn; access_log off; error_log off; # ssl配置省略 # 其餘解析省略 location / { proxy_pass http://192.168.1.1; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_http_version 1.1; } } server { listen 80; server_name abc.cn; access_log off; error_log off; location / { rewrite ^/(.*) http://www.abc.cn$request_uri? permanent; } } server { listen 443 ssl; server_name abc.cn; access_log off; error_log off; # ssl配置省略 location / { rewrite ^/(.*) https://www.abc.cn$request_uri? permanent; } }