在nginx服务器中,场景是在子文件夹mydomain中安装Wordpress。com/new,具有特定于域的nginx配置(conf.d/mydomain.com.conf),如下所示:
server {
listen 80;
server_name mydomain.com *.mydomain.com;
root /var/www/mydomain;
index index.php index.html index.htm;
# error_log /var/log/nginx/mydomain-error.log warn;
aio threads;
set_real_ip_from 127.0.0.1;
set_real_ip_from 10.0.0.0/8;
real_ip_header X-Real-IP;
add_header Via "1.1 varnish-v4.1";
gzip_vary off; # already handled from upstream server
include includes/cloudflare.conf;
include includes/fastcgi-wordpress.conf;
location / {
try_files $uri $uri/ /index.php?$args /index.php?q=$uri&$args;
expires 30d;
}
# Deny access to uploads that aren’t images, videos, music, etc.
location ~* ^/wp-content/uploads/.*.(html|htm|shtml|php|js|swf)$ {
deny all;
}
# Deny public access to wp-config.php
location ~* wp-config.php {
deny all;
}
# Deny access to wp-login.php. Do not enable due to admin-ajax.php!! T_T
# location = /(wp-login|login).php {
# limit_req zone=one burst=1 nodelay;
# fastcgi_pass 127.0.0.1:9000;
# }
location ~ \\.php$ {
try_files $uri /index.php;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
include includes/fastcgi-http.conf;
}
# location ~ /purge(/.*) {
# fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1";
# }
location ~* ^.+\\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off;
log_not_found off;
expires max;
}
location = /robots.txt {
access_log off;
log_not_found off;
}
location ~ /\\. {
deny all;
access_log off;
log_not_found off;
}
}
mydomain。com运行正常,但在mydomain中。com/new |所有媒体和永久链接保持重定向到mydomain。com而不是mydomain。com/新。应该修改哪个配置来修复此问题?我对这个nginx配置不熟悉,如果配置失败,如何防止整个服务器/域出错(此服务器中有多个域),非常感谢您的帮助。