WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/25/2017 12:53:47 AM (3 years ago)
Author:
pento
Message:

REST API: Always add index.php to the REST URL when pretty permalinks are disabled.

When pretty permalinks are disabled, the web server will internally forward requests to index.php. Unfortunately, nginx only forwards HTTP/1.0 methods: PUT, PATCH, and DELETE methods will return a 405 error.

To work around this nginx behaviour, including index.php in the REST URL skips the internal redirect.

Merges 41139 to the 4.8 branch.
Fixes #40886.

Location:
branches/4.8
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.8

  • branches/4.8/src/wp-includes/rest-api.php

    r40843 r41140  
    325325    } else {
    326326        $url = trailingslashit( get_home_url( $blog_id, '', $scheme ) );
     327        // nginx only allows HTTP/1.0 methods when redirecting from / to /index.php
     328        // To work around this, we manually add index.php to the URL, avoiding the redirect.
     329        if ( 'index.php' !== substr( $url, 9 ) ) {
     330            $url .= 'index.php';
     331        }
    327332
    328333        $path = '/' . ltrim( $path, '/' );
Note: See TracChangeset for help on using the changeset viewer.