nginx Wordpress URL rewrite

2019-05-17 01:51发布

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.

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

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;
    }

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

What am I missing?

2条回答
ら.Afraid
2楼-- · 2019-05-17 02:30

Did you try restarting nginx after you have saved your config?

Also, check out my nginx/WordPress setup guide here:

http://themesforge.com/featured/high-performance-wordpress-part-3/

查看更多
虎瘦雄心在
3楼-- · 2019-05-17 02:38

Could be the permission of the root site folder

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;
    }

}

查看更多
登录 后发表回答