使用以下代碼得出的結果是,不帶www的域名,可以正常跳轉帶www域名,HTTP狀態回傳顯示301(正確)
但是發現有個問題就是,直接訪問https://fphs5.com/不會跳轉,HTTP狀態回傳顯示200(錯誤)
想讓https://fphs5.com/這個域名,正常301跳轉到https://www.fphs5.com/
請各位大牛指示一下
代碼如下:【服務器Nginx】
server
{
listen 80;
#listen [::]:80;
server_name www.fphs5.com fphs5.com;
if ($host != 'www.fphs5.com' ) {
rewrite ^/(.*)$ https://www.fphs5.com/$1 permanent;
} index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/www.fphs5.com;
include phpcms.conf;
include other.conf;
error_page 404 /404.html;
if ($ssl_protocol = "") { return 301 https://$host$request_uri; }
include enable-php.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /\.
{
deny all;
}
location ~*(/chuangyi/data/|/chuangyi/templets/|/feipin/data/|/feipin/templets/|/tupian/data/|/tupian/templets/)
{
deny all;
return 404;
}
access_log off;
}
server
{
listen 443 ssl http2;
#listen [::]:443 ssl http2;
server_name www.fphs5.com fphs5.com;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/www.fphs5.com;
ssl on;
ssl_certificate /usr/local/nginx/conf/ssl/www.fphs5.com/fullchain.cer;
ssl_certificate_key /usr/local/nginx/conf/ssl/www.fphs5.com/www.fphs5.com.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";
ssl_session_cache builtin:1000 shared:SSL:10m;
# openssl dhparam -out /usr/local/nginx/conf/ssl/dhparam.pem 2048
ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem;
include phpcms.conf;
error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
include enable-php-pathinfo.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
access_log off;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/143845.html
標籤:非技術區
上一篇:centos7
