开发者

Rewrite Rules for Subdirectories in Wordpress 3 Multiuser with nginx?

My Wordpress 3 multiuser has been enabled, but I don't know how to rewrite the following .htaccess rules for nginx:

RewriteEngine On
RewriteBase开发者_JS百科 /
RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [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]

Any hints?


These codes do not work:(I have done some changes with them, but still not work in wordpress3.0.1)

    rewrite ^index\.php$ - last;

    # uploaded files
    rewrite ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 last;

    # add a trailing slash to /wp-admin
    rewrite ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ permanent;

    if ( -e $request_filename ) {
            rewrite ^ - last;
            rewrite ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 last;
            rewrite ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 last;
            rewrite . index.php last;
    }

I have tried it

I built wordpress3.0.1 in virtualbox with apache2, just finding the .htaccess file was shown below:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]

so the nginx rewrite rule should be those:

location ~ / {
    rewrite ^index\.php$ - last;
    if( !-e $request_filename ) {
        rewrite . /index.php last;
    }
}

and this works!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜