Wordpress 3.0 rewrite Rules in nginx
The multi-site feature has been enabled in wordpress recently, and the test is normal. However, when I insert an image in the article, I encountered a problem. Follow the previous installation settings. One step is to create the blogs. dir directory under the wp-content directory to store the files uploaded by the user. When an image is inserted in an article, the image can be uploaded to the corresponding directory normally, for example, wp-content/blogs. dir/blogid/files/2010/10/image.png, where blogid is the number of each blog. However, I cannot display it normally in the article because the server environment I use is nginx, so I need to update the wordpress 3.0 rewrite rule.
The rules applicable to apache are as follows:
RewriteEngine On
RewriteBase/
RewriteRule ^ index \. php $-[L]
# Uploaded files
RewriteRule ^ files/(. +) wp-nodes des/ms-files.php? File = $1 [L]
RewriteCond % {REQUEST_FILENAME}-f [OR]
RewriteCond % {REQUEST_FILENAME}-d
RewriteRule ^-[L]
RewriteRule. index. php [L]
Write it to The. htaccess file under the root directory of the website.
Modify the following rules in nginx:
# On server block
# Necessary if using a multi-site plugin
Server_name_in_redirect off;
# Necessary if running Nginx behind a reverse-proxy
Port_in_redirect off;
Rewrite ^. */files/(. *) $/wp-nodes des/ms-files.php? File = $1 last;
If (! -E $ request_filename ){
Rewrite ^. +? (/Wp-. *) $1 last;
Rewrite ^. +? (/. *. Php) $1 last;
Rewrite ^/index. php last;
}
Write the nginx site configuration file and restart the nginx server.
Reference: http://imcat.in/nginx-wordpress-3-0-rewrite/