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 /
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?

Related posts

Leave a Reply

1 comment

  1. 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!