[wp-trac] [WordPress Trac] #18852: Nginx rewrite rules
WordPress Trac
wp-trac at lists.automattic.com
Thu Jun 28 08:22:32 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 |
-------------------------------------+--------------------------
Changes (by johnbillion):
* keywords: has-patch needs-refresh => has-patch needs-testing
Comment:
[attachment:18852.3.patch] is a tentatively updated patch (against
r21157).
Included in the patch are single site rewrite rules which are displayed on
the Permalinks screen, and Multisite rewrite rules which are displayed on
the Network Setup screen.
The `try_files` directive (?) has been updated as per [comment:5 Nacin's
suggestion].
The Multisite rules '''will need verifying for correctness''' as they are
not the same as those found on the [http://codex.wordpress.org/Nginx Codex
page for nginx]. Instead they more closely resemble the mod_rewrite and
IIS rewrite rules for Multisite. I have just deployed these rewrite rules
to an nginx site of mine, but I've yet to test them thoroughly.
{{{
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
# Uploaded files
rewrite ^/([_0-9a-zA-Z-]+/)?files/(.+) /wp-includes/ms-files.php?file=$2
last;
# Add trailing slash to /wp-admin
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
if (!-e $request_filename) {
rewrite ^/[_0-9a-zA-Z-]+(/wp-(content|admin|includes).*) $1 last;
rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
}
}}}
In addition, I don't believe the rewrite rules take into account '''single
sites installs in subdirectories'''. I've not tested it. We may need to
include the base subdirectory (eg. `/foo` for a site at `example.com/foo`
at the start of each rewrite rule as nginx doesn't have a RewriteBase
equivalent.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/18852#comment:9>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list