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. Built from https://develop.svn.wordpress.org/trunk@41139 git-svn-id: http://core.svn.wordpress.org/trunk@40979 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b4c2f16d01
commit
7819daefd2
|
@ -324,6 +324,11 @@ function get_rest_url( $blog_id = null, $path = '/', $scheme = 'rest' ) {
|
||||||
$url .= '/' . ltrim( $path, '/' );
|
$url .= '/' . ltrim( $path, '/' );
|
||||||
} else {
|
} else {
|
||||||
$url = trailingslashit( get_home_url( $blog_id, '', $scheme ) );
|
$url = trailingslashit( get_home_url( $blog_id, '', $scheme ) );
|
||||||
|
// nginx only allows HTTP/1.0 methods when redirecting from / to /index.php
|
||||||
|
// To work around this, we manually add index.php to the URL, avoiding the redirect.
|
||||||
|
if ( 'index.php' !== substr( $url, 9 ) ) {
|
||||||
|
$url .= 'index.php';
|
||||||
|
}
|
||||||
|
|
||||||
$path = '/' . ltrim( $path, '/' );
|
$path = '/' . ltrim( $path, '/' );
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.9-alpha-41138';
|
$wp_version = '4.9-alpha-41139';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue