Make WordPress Core

Opened 7 years ago

Last modified 3 years ago

#18852 closed enhancement

Nginx rewrite rules — at Version 3

Reported by: johnbillion Owned by:
Milestone: 4.4 Priority: low
Severity: minor Version: 3.3
Component: Rewrite Rules Keywords: needs-patch
Focuses: administration Cc:

Description (last modified by dd32)

On the Permalinks screen we show rewrite rules for IIS and for mod_rewrite on Apache. Nginx is getting pretty popular now, so we should think about showing Nginx rewrite rules on this screen.

Unfortunately WordPress can't write directly to Nginx's rewrite configuration, but we can show the required rules for convenience and we can allow plugins to filter them if necessary (in the samw way IIS and mod_rewrite rules can be filtered).

Change History (5)

7 years ago

#1 @johnbillion
7 years ago

  • Keywords has-patch added

First pass at a patch to see where it gets us.

got_url_rewrite() is a new function which is a wrapper for detecting if we've got any method enabled for URL rewrites (mod_rewrite, IIS7 with permalinks, or Nginx).

The suggested rewrite rules are what I'm running on a couple of sites and what seems to be the most popular form of rewrites for WordPress on Nginx.

Patch also introduces a new $is_nginx global.

Thoughts, suggestions & feedback welcome.

#3 @dd32
7 years ago

  • Description modified (diff)

Those rules can be slimed down a bit, no need to check for the file-exists check as try_files handles that through it's priority queue:

location / {
    try_files $uri $uri/ /index.php$args;

ie. If File exists, Elseif, If it's a Directory, Else, Lets pass it to WordPress

7 years ago

Note: See TracTickets for help on using tickets.