【发布时间】:2014-10-24 16:53:44
【问题描述】:
我在使用 nginx 和一些 wordpress 网站设置子域时遇到问题。
我的 www.jackalopegames.com 域正在运行,但我想设置 dev.jackalopegames.com。
这是我启用站点的文件夹中的配置文件:
server
{
listen 80;
server_name jackalopegames.com www.jackalopegames.com;
include /etc/nginx/fastcgi_php;
root /var/sitefolder;
index index.php;
}
server {
listen 80;
server_name dev.jackalopegames.com;
include /etc/nginx/fastcgi_php;
root /var/devfolder;
index index.php;
}
第一个 server_name jackalopegames.com 有效,但第二个无效。我环顾了一堆,我不知道为什么这不起作用。任何提示将不胜感激!
更新:
我已将以下内容添加到我的子域server {...},但没有任何效果:
location / {
root /var/dev;
index index.php;
rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last;
if (!-e $request_filename) {
rewrite ^.+/?(/wp-.*) $1 last;
rewrite ^.+/?(/.*\.php)$ $1 last;
rewrite ^(.+)$ /index.php?q=$1 last;
}
}
location ~* ^.+\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$
{
root /var/dev;
rewrite ^/.*(/wp-.*/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ $1 last;
rewrite ^.*/files/(.*(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$/wp-includes/ms-files.php?file=$1 last;
expires 30d;
break;
}
location ~ wp\-.*\.php|wp\-admin|\.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/dev$fastcgi_script_name;
}
}
【问题讨论】: