[wp-trac] [WordPress Trac] #29945: Network setup rules should have a line break at the end

WordPress Trac noreply at wordpress.org
Sun Oct 12 23:10:23 UTC 2014


#29945: Network setup rules should have a line break at the end
--------------------------------+----------------------------------------
 Reporter:  SergeyBiryukov      |      Owner:
     Type:  defect (bug)        |     Status:  new
 Priority:  normal              |  Milestone:  4.1
Component:  Networks and Sites  |    Version:
 Severity:  normal              |   Keywords:  needs-patch good-first-bug
  Focuses:  multisite           |
--------------------------------+----------------------------------------
 The standard WordPress `.htaccess` rules look like this:
 {{{
 # BEGIN WordPress
 <IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase /
 RewriteRule ^index\.php$ - [L]
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule . /index.php [L]
 </IfModule>

 # END WordPress
 }}}

 When creating a network, the suggested rules are:
 {{{
 RewriteEngine On
 RewriteBase /
 RewriteRule ^index\.php$ - [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]
 }}}

 Before pasting them into `.htaccess`, I generally remove all existing
 rules, including the `BEGIN/END` comments and the `<IfModule>` tag.

 However, if you keep those, it's too easy to make an error:
 {{{
 # BEGIN WordPress
 <IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase /
 RewriteRule ^index\.php$ - [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]</IfModule>

 # END WordPress
 }}}

 Note the problematic line at the end:
 {{{
 RewriteRule . index.php [L]</IfModule>
 }}}
 It leads to a 500 Internal Server Error on some installs and to 404 Not
 Found errors on others.

 It should be two separate lines:
 {{{
 RewriteRule . index.php [L]
 </IfModule>
 }}}

 We should add a line break to the end of the network setup rules to reduce
 the chance of this issue.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/29945>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list