开发者

Rewrite rules for wordpress 3.0 (multi-site) for nginx?

开发者 https://www.devze.com 2022-12-20 15:10 出处:网络
This is the new version being used by wordpress... RewriteEngine On RewriteBase BASE/ #uploaded files RewriteRule ^(.*/)?files/$ index.php [L]

This is the new version being used by wordpress...

RewriteEngine On
RewriteBase BASE/

#uploaded files
RewriteRule ^(.*/)?files/$ index.php [L]
RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
RewriteRule ^(.*/)?files/(.*) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteCond %{REQUEST_URI} ^.*/wp-admin$
RewriteRule ^(.+)$ $1/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

What would i开发者_JAVA百科t look like in Nginx?


location / {
 root   /your/document/root;
 index  index.html index.htm index.php;
 if (!-e $request_filename) {
        rewrite ^.+/?(/wp-.*) $1 last;
        rewrite ^.+/?(/.*\.php)$ $1 last;
        rewrite ^(.+)$ /index.php?q=$1 last;
        }
 }

 location ~* ^.+\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$
        {
        root /your/document/root;
        rewrite ^/.*(/wp-.*/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ $1 last;

        rewrite ^.*/files/(.*(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$/wp-includes/ms-files.php?file=$1 last;
        expires 30d;
        break;
        }


It depends how do you want to use WordPress Multisite.

For Multisite with Subdomain - http://rtcamp.com/tutorials/nginx-wordpress-multisite-subdomains-domain-mapping/

For Multisite with Subdirectory - http://rtcamp.com/tutorials/wordpress-nginx-multisite-subdirectories-nginx-map/

You will need to add some more rules depending on which cache plugin/mechanism you plan to use. (ref)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号