简体   繁体   English

从apache到nginx:wordpress重写规则

[英]From apache to nginx: wordpress rewrite rule

I'm migrating from apache2 to nginx. 我正在从apache2迁移到nginx。 I cant figure out how to to rewrite this rewrite rules for wordpress. 我无法弄清楚如何重写 wordpress的重写规则

This is actually my configuration file 这实际上是我的配置文件

server {
        listen 80;    
        root /usr/share/nginx/blog.com/public_html;
        index index.html index.htm index.php;

        server_name blog.com www.blog.com;

        location / {
                try_files $uri $uri/ /index.html;

        }

        location /doc/ {
                alias /usr/share/doc/;
                autoindex on;
                allow 127.0.0.1;
                allow ::1;
                deny all;
        }

        location ~ .php$ {
                fastcgi_pass 127.0.0.1:9000;

                fastcgi_param  SCRIPT_FILENAME /usr/share/nginx/blog.com/public_html$fastcgi_script_name;
                fastcgi_index index.php;
                include fastcgi_params;
        }

}

I'm using php5-fpm. 我正在使用php5-fpm。

And this is the rule I would like to add : 这是我想补充的规则:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>

# END WordPress

Can you please help me? 你能帮我么? Thanks :) 谢谢 :)

You should read http://wiki.nginx.org/WordPress 你应该阅读http://wiki.nginx.org/WordPress

eg 例如

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

    location ~ \.php$ {
            fastcgi_split_path_info ^(/blog)(/.*)$;
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM