是否可以在一个域下托管多个wp安装,并使用Nginx将每个安装作为子文件夹?我已尝试与配置文件的所有可能组合,并继续被抛到404页面。如果有办法让try_files查看每个使用的url的文件夹内部,那就太酷了。
location / {
try_files $uri $uri/ /$some-folder/index.php?$args;
}
有没有办法告诉nginx它应该在每个使用的网址的文件夹中查找?通过网址我的意思是这样的。有永久链接的问题。
domain.com/wp-installation-1
domain.com/wp-installation-2
domain.com/wp-installation-3
我已经检查了stackoverflow中的其他帖子,似乎没有人找到解决方案。我应该回到apache这个吗?我很惊讶nginx没有解决方案。
这是我的配置文件
server {
listen 80;
server_name 104.131.123.171;
return 301 http://www.sharkstaging.com;
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
#this wont work so i've commented it out
#location /wp {
# tryfiles $uri $uri/ /index.php?q=$uri&$args;
#}
#tried doing something like this but wont work, i'm sure its something wrong
location /wp1 {
tryfiles $uri $uri/ /wp/index.php?q=$uri&$args;
}
location /wp2 {
tryfiles $uri $uri/ /wp/index.php?q=$uri&$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
#location /RequestDenied {
# proxy_pass http://127.0.0.1:8080;
#}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root /usr/share/nginx/html;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
location = /robots.txt { access_log off; log_not_found off; }
location ~ /\. { deny all; access_log off; log_not_found off; }
}