nginx Wordpress URL rewrite

廉价感情. 提交于 2020-01-02 07:13:19

问题


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?


回答1:


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

}




回答2:


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/



来源:https://stackoverflow.com/questions/7820462/nginx-wordpress-url-rewrite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!