业务实际需要,需要使用wordpress配置公司中英文站点,nginx、php、wordpress安装见站内其他文章,nginx配置如下:
############www.demo-cloud.com################################3 upstream demo { server 127.0.0.1:9000; } server { listen 80; server_name www.demo-cloud.com; rewrite ^(.*)$ https://$host$1 permanent; } server { listen 443 ssl; server_name www.demo-cloud.com; ssl_certificate demo.pem; ssl_certificate_key demo.key; ssl_session_timeout 5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES'; ssl_prefer_server_ciphers on; index index.php index.html index.htm default.php default.htm default.htm; root /app/demo; access_log logs/www.demo-cloud.com.log log_json; allow 58.33.3.246/32; allow 101.52.254.25/32; deny all; ####设置访问主页重定向到中文网站 location / { if ($host = 'www.demo-cloud.com') { rewrite ^/(.*)$ http://www.demo-cloud.com/cn permanent; } } ####设置英文网站对应的目录 location /en { if (-f $request_filename/index.html){ rewrite (.*) $1/index.html break; } if (-f $request_filename/index.php){ rewrite (.*) $1/index.php; } if (!-f $request_filename){ rewrite (.*) /en/index.php; } } ####设置中文网站对应的目录 location /cn { if (-f $request_filename/index.html){ rewrite (.*) $1/index.html break; } if (-f $request_filename/index.php){ rewrite (.*) $1/index.php last; } if (!-f $request_filename){ rewrite (.*) /zh/index.php last; } } ########设置php转发参数 location ~ \.php$ { try_files $uri =404; fastcgi_pass demo; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } if ($request_method !~ ^(GET|HEAD|POST)$ ) { return 501; } proxy_intercept_errors on; error_page 500 502 503 504 /50x.html; error_page 404 /404.html; location ~ /(404|50x).html { root html/errorHtml; } location ~ .*/errorHtml/ { rewrite ^/.*/(errorHtml/.*)$ /$1 permanent; access_log off; } location = /favicon.ico { log_not_found off; access_log off; } }
附上nginx配置文件,供大家参考。