Wordpress 3.0 rewrite Rules in nginx

Source: Internet
Author: User
Tags nginx server

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/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.