[wp-trac] [WordPress Trac] #18852: Nginx rewrite rules

WordPress Trac wp-trac at lists.automattic.com
Thu Jun 28 19:07:08 UTC 2012


#18852: Nginx rewrite rules
-------------------------------------+--------------------------
 Reporter:  johnbillion              |       Owner:  johnbillion
     Type:  enhancement              |      Status:  accepted
 Priority:  normal                   |   Milestone:  3.5
Component:  Rewrite Rules            |     Version:  3.3
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |
-------------------------------------+--------------------------

Comment (by devesine):

 '''Multisite:'''

 In the ms-files directive:

 {{{
 $nginx_config_file .= 'rewrite ^/' . ( $subdomain_install ? '' : '([_0-9a-
 zA-Z-]+/)?' ) . 'files/(.+) /wp-includes/ms-files.php?file=$2 last;' .
 "\n\n";
 }}}

 $2 should be $1 if $subdomain_install is true (since there isn't the
 subdomain regex capture group, then), something like like so:

 {{{
 $nginx_config_file .= 'rewrite ^/' . ( $subdomain_install ? '' : '([_0-9a-
 zA-Z-]+/)?' ) . 'files/(.+) /wp-includes/ms-files.php?file=' . (
 $subdomain_install ? '$2' : '$1 ) . ' last;' . "\n\n";
 }}}

 Aside from that, these directives work correctly as far as I can tell for
 multisite installs.

 '''Single site installed in a subdirectory'''

 As you observed, these rules do not take into account a single site which
 is installed in a subdirectory (WP_SITEURL and WP_HOME both
 'http://example.com/blog', or WP_SITEURL 'http://example.com/blog/wp' and
 WP_HOME 'http://example.com/blog').  Adding the base subdirectory to the
 location directive and the index.php part of try_files works fine:

 {{{
         location /blog {
                 try_files $uri $uri/ /blog/index.php$is_args$args;
         }
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/18852#comment:11>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list