Opened 11 years ago
Closed 11 years ago
#29945 closed defect (bug) (fixed)
Network setup rules should have a line break at the end
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 4.1 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Networks and Sites | Keywords: | good-first-bug has-patch |
| Focuses: | multisite | Cc: |
Description
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.
Attachments (1)
Change History (5)
This ticket was mentioned in IRC in #wordpress-dev by DrewAPicture. View the logs.
11 years ago
Note: See
TracTickets for help on using
tickets.
Yep. This broke my multisite install. Thanks for finding the issue, @sergeybiryukov!