WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 15 months ago

#18852 accepted enhancement

Nginx rewrite rules — at Version 3

Reported by: johnbillion Owned by:
Milestone: Future Release Priority: normal
Severity: minor Version: 3.3
Component: Rewrite Rules Keywords: has-patch needs-testing
Focuses: 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)

@johnbillion4 years ago

comment:1 @johnbillion4 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.

comment:3 @dd324 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

@johnbillion4 years ago

Note: See TracTickets for help on using tickets.