nginx Wordpress URL重写 [英] nginx Wordpress URL rewrite

查看:196
本文介绍了nginx Wordpress URL重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了nginx 1.0.8和php-fpm,在过去的30分钟里,我正尝试为Wordpress重写URL.

I've just installed nginx 1.0.8 and php-fpm and for the last 30 minutes I'm trying to rewrite the URL for Wordpress.

以下是Wordpress URL的外观: http://localhost/website/blog/2011/10/sample-post/

Here is what the Wordpress URL should look like: http://localhost/website/blog/2011/10/sample-post/

我看过本教程: http://wiki.nginx.org/WordPress +网络上还有很多其他功能,但是每次我收到404错误(有时是403)时.

I've looked at this tutorial: http://wiki.nginx.org/WordPress + many other on the web but every time I receive an 404 error (sometimes 403).

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

Here is what I did in my configuration file:

    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禁止访问"状态.

With this configuration I'm receiving "403 forbidden" status.

我想念什么?

推荐答案

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

Could be the permission of the root site folder

这是我用于wordpress的示例

This is an example that i use to 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;
    }

}

这篇关于nginx Wordpress URL重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆