在我的wordpress网站的nginx配置中,我有以下配置。
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name localhost;
root /var/www;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php$is_args$args;
# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
}
location ~ \.php$ {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, DELETE, PUT';
#
# Custom headers and headers various browsers *should* be OK with but aren't
#
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,X-Socket-Id,X-CSRF-TOKEN,Authorization';
#
# Tell client that this pre-flight info is valid for 20 days
#
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' '*';
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*';
}
if ($request_method = 'PUT') {
add_header 'Access-Control-Allow-Origin' '*';
}
if ($request_method = 'DELETE') {
add_header 'Access-Control-Allow-Origin' '*';
}
try_files $uri /index.php =404;
fastcgi_pass php-upstream;
fastcgi_index index.php;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fixes timeouts
fastcgi_read_timeout 600;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
location ~ /debug\.log$ {
deny all;
}
location /wp-content/uploads/ {
proxy_pass https://s3-ap-northeast-1.amazonaws.com/project-storage/wp-content/uploads/;
proxy_intercept_errors on;
if ($request_uri ~* ".css$") {
add_header Content-Type text/css;
}
}
location /.well-known/acme-challenge/ {
root /var/www/letsencrypt/;
log_not_found off;
}
}
map $http_user_agent $log_ua {
~ELB-HealthChecker 0;
~Amazon-Route53-Health-Check-Service 0;
default 1;
}
通过上述配置,我可以访问https://site-domain.com/wp-admin/
,但是在尝试访问https://site-domain.com/wp-admin
时,浏览器加载程序(Chrome浏览器的左上方)保持旋转。
在“网络”标签中,我得到以下信息:
我也尝试添加:
remove_filter('template_redirect', 'redirect_canonical');
文件中的 functions.php
,如此thread所建议的那样使用,并在配置文件中添加了代码:
# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
但是没有一个主题在起作用。如果有人可以帮助我,我将非常感激。