Home > OS >  Domain name under centos jump problem
Domain name under centos jump problem

Time:10-28

using the following code concluded as a result, the domain name without the WWW, can jump with the WWW domain name, normal HTTP status returns show 301 (right)
But found that there is a problem is, direct access to the https://fphs5.com/will not jump, HTTP status returns show 200 (error)
Want to make the domain name https://fphs5.com/, normal 301 jump to https://www.fphs5.com/
Daniel, please indicate the


The code is as follows: [Nginx server]
 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. The default PHP, HTML default. HTM. Default PHP;
Root/home/wwwroot/www.fphs5.com;
The include PHPCMS. Conf;
Include other. Conf;
Error_page 404/404. HTML;
If ($ssl_protocol="") {return 301 https://$host$request_uri; }
Include the enable - PHP. Conf.

The location ~. * \. (GIF | JPG | jpeg | PNG | BMP | SWF) $
{
expires 30d;
}

The location ~. * \. (js) | CSS? $
{
Expires 12 h;
}

The location ~/\.
{
Deny all;
}
The location ~ * (/chuangyi/data/|/chuangyi/templets/|/feipin/data/|/feipin/templets/|/tupian/data/|/tupian/templets/)
{
Deny all;
return 404;
}
Access_log off;
}

Server
{
443 SSL http2 listen;
SSL http2 # listen [: :] : 443.
Server_name www.fphs5.com fphs5.com;
Index index. HTML index. HTM index. The default PHP, 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 5 m;
Ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
Ssl_ciphers "EECDH + CHACHA20: EECDH + CHACHA20 - draft: EECDH + either AES128: RSA + either AES128: EECDH + AES256: RSA + AES256: EECDH + 3 des, RSA + 3 des:! MD5 ";
Ssl_session_cache builtin: 1000 Shared: SSL: 10 m;
# openssl dhparam - out/usr/local/nginx/conf/SSL/dhparam pem 2048
Ssl_dhparam/usr/local/nginx/conf/SSL/dhparam pem.

The include PHPCMS. Conf;
Error_page 404/404. HTML;

# to Deny access to the PHP files in specific directory
# the location ~/(wp - content | uploads | wp - includes | images)/. * \. PHP ${deny all; }

Include the enable - PHP - pathinfo. Conf;

The location ~. * \. (GIF | JPG | jpeg | PNG | BMP | SWF) $
{
expires 30d;
}

The location ~. * \. (js) | CSS? $
{
Expires 12 h;
}

The location ~/. Well - known {
Allow all;
}

The location ~/\.
{
Deny all;
}

Access_log off;
}
  • Related