2011-10-19 259 views
3

我刚刚安装了nginx 1.0.8和php-fpm,并且最近30分钟我正在尝试重写Wordpress的URL。nginx WordPress的URL重写

这里是WordPress的URL应该是什么样子: http://localhost/website/blog/2011/10/sample-post/

我已经看了本教程:http://wiki.nginx.org/WordPress +许多其他网站,但每次在我收到一个404错误(有时是403)。

以下是我在配置文件中所做的:

location /website/blog { 
      try_files $uri $uri/ /website/blog/index.php; 
    } 

    location ~ \.php$ { 
     root   html; 
     fastcgi_pass 127.0.0.1:9000; 
     fastcgi_index index.php; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     fastcgi_intercept_errors on; 
     fastcgi_split_path_info ^(/website/blog)(/.*)$; 
     include  fastcgi_params; 
     error_page 404 /404.html; 
    } 

有了这个配置我收到“403禁止”状态。

我错过了什么?

+0

检查你的日志 – user973254

回答

0

可能是根站点文件夹的权限

这是我使用WordPress的一个例子

server { 
listen 80; 
server_name www.mysite.com mysite.com; 
root /srv/www/mysite.com/public_html; 
location/{ 
    index index.html index.htm index.php; 
    try_files $uri $uri/ /index.php?$args; 
} 
rewrite /wp-admin$ $scheme://$host$uri/ permanent; 
include /srv/www/mysite.com/public_html/*.conf; 
location ~ \.php$ { 
      try_files $uri =404; 
      fastcgi_pass unix:/var/run/php5-fpm.sock; 
      fastcgi_index index.php; 
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
      include fastcgi_params; 
    } 

}