所以我在我的服务器上安装了nginx和Wordpress。 但是,我的博客不在域根。 (例如example.com/blog ,内容位于/var/www/example.com/blog )
我在nginx中使用下面的设置,我的Wordpress安装使用Apache中的URL重写规则。 (例如像example.com/blog/2012/hello-world永久链接)
但是,有趣的是,所有这些URL重写规则都进入了/ (而不是在blog/ )中的index.php 。 我想解决,但我不知道如何。 另一个有趣的事情是, example.com/blog (主页)工作正常。
例如,因为example.com/blog/2012/hello-world不是真正的文件,所以try_files正在执行example.com/index.php 。 (url保持不变,但index.php得到执行)。 任何帮助表示赞赏!
server { listen 80; root /var/www/example.com; index index.php; server_name 192.34.59.214; location / { try_files $uri $uri/ /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/www; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9$ location ~ \.php$ { #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; } }
你需要另一个location部分的WordPress。
location /blog/ { try_files $uri $uri/ /blog/index.php }