当wordpress不在主目录中时,wordpress url会在nginx上重写

出于某种原因,我总是遇到麻烦让Wordpress在Nginx上工作。

我有我的Wordpress安装在文件夹“网站”(在public_html)。 这是我的nginxconfiguration:

server { server_name www.wouterds.be wouterds.be; access_log /srv/www/www.wouterds.be/logs/access.log; error_log /srv/www/www.wouterds.be/logs/error.log; location / { root /srv/www/www.wouterds.be/public_html; index index.php index.html index.htm; try_files $uri $uri/ /site/index.php?$args; autoindex on; } location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_pass unix:/var/run/php-fastcgi/php-fastcgi.socket; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /srv/www/www.wouterds.be/public_html$fastcgi_script_name; } } 

当我访问我的网站http://wouterds.be/,我只得到目录索引。 当我访问http://wouterds.be/blog/我得到正确的网页,一切工作。 但我不知道如何让它在基地url上工作。

任何人谁可以帮我一下? 我当然不是一个nginx专家,经过4个小时Google,我决定在这里试试。

您也可以尝试(不在位置块中):

 rewrite /wp-admin$ $scheme://$host$uri/ last; rewrite ^/(wp-.*.php)$ /wp/$1 last; rewrite ^/(wp-(content|admin|includes).*) /wp/$1 last; 

Exchange /wp/ for /wordpress/或者其他目录。

资源:

https://wordpress.stackexchange.com/questions/138648/nginx-rules-for-subdomain-multisite-install-bedrock

只是改变:

  root /srv/www/www.wouterds.be/public_html; 

  root /srv/www/www.wouterds.be/public_html/site; 

假设WordPress的index.php是site文件夹内。

也移动root线以外的location块。

你可以试试…

 server { #other stuff root /srv/www/www.wouterds.be/public_html/site ; location / { root /srv/www/www.wouterds.be/public_html; index index.php index.html index.htm; try_files $uri $uri/ /site/index.php?$args; autoindex on; } #other stuff }