Make WordPress Core


Ignore:
Timestamp:
07/25/2017 12:49:22 AM (7 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.

Fixes #40886.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api.php

    r40843 r41139  
    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.