我正在将一个Wordpress网站从Apache切换到Nginx。
我们试图模糊它是一个Wordpress网站的事实(我不知道为什么,但这些是要求)。
在wordpress目录中有一些静态资产调用,所以它并不完美。
在大多数情况下,它正在运行(www.example.com和其他正确显示的页面),但我无法让Admin页面正常工作。
当您访问example.com/wp-admin时,服务器应该加载/var/example.com/docroot/wordpress/wp-admin/index.php,但我会继续获得404.
我不确定我哪里出错了。这是我的服务器配置:
server {
server_name *.example.com;
root /var/example.com/docroot;
access_log logs/access.log;
error_log logs/error.log debug ;
gzip off;
# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
# Rewrite wp-content to pretend we don't use Wordpress
location ~ ^/content/(.*)$ {
alias /var/example.com/docroot/wordpress/wp-content/$1;
}
location ~ ^/wp-content/(.*)$ {
alias /var/example.com/docroot/wordpress/wp-content/$1;
}
location ~ ^/includes/(.*)$ {
alias /var/example.com/docroot/wordpress/wp-includes/$1;
}
location ~ ^/wp-includes/(.*)$ {
alias /var/example.com/docroot/wordpress/wp-includes/$1;
}
location /wp-admin {
alias /var/example.com/docroot/wordpress/wp-admin;
}
# Basic php configuration
location ~ \.php$ {
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
try_files $uri =404;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
# static assets and blocking specific access
include sites-enabled/common.conf;
}
答案 0 :(得分:0)
我为实现这一目标所做的两件事:
Proxy_pass而不是别名
location /wp-admin {
proxy_pass $scheme://www.dev4.railrode.net/wordpress/wp-admin/;
}
对于try_files指令,添加了一个wordpress $ uri选项:
try_files $uri /wordpress$uri =404