2013-03-22 80 views
6

我正在從apache2遷移到nginx。我無法弄清楚如何爲wordpress重寫這個重寫規則從apache到nginx:wordpress重寫規則

其實,這是我的配置文件

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

} 

我使用PHP5-FPM。

,這是我想規則補充:

# 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 

你能幫幫我嗎?謝謝:)

回答

14

您應該閱讀http://wiki.nginx.org/WordPress

例如,

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

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