Ticket #40886: 40886.diff
File 40886.diff, 1.5 KB (added by , 8 years ago) |
---|
-
src/wp-includes/rest-api.php
308 308 * @return string Full URL to the endpoint. 309 309 */ 310 310 function get_rest_url( $blog_id = null, $path = '/', $scheme = 'rest' ) { 311 global $is_nginx; 311 312 if ( empty( $path ) ) { 312 313 $path = '/'; 313 314 } … … 324 325 $url .= '/' . ltrim( $path, '/' ); 325 326 } else { 326 327 $url = trailingslashit( get_home_url( $blog_id, '', $scheme ) ); 328 // nginx only allows HTTP/1.0 methods when redirecting from / to /index.php 329 // To work around this, we manually add index.php to the URL, avoiding the redirect. 330 if ( $is_nginx && 'index.php' !== substr( $url, 9 ) ) { 331 $url .= 'index.php'; 332 } 327 333 328 334 $path = '/' . ltrim( $path, '/' ); 329 335 -
tests/phpunit/tests/rest-api.php
316 316 $this->set_permalink_structure( '' ); 317 317 $this->assertEquals( 'http://' . WP_TESTS_DOMAIN . '/?rest_route=/', get_rest_url() ); 318 318 319 // nginx requires index.php in non-pretty permalinks. 320 global $is_nginx; 321 $is_nginx_backup = $is_nginx; 322 $is_nginx = true; 323 324 $url = get_rest_url(); 325 326 $is_nginx = $is_nginx_backup; 327 328 $this->assertEquals( 'http://' . WP_TESTS_DOMAIN . '/index.php?rest_route=/', $url ); 319 329 } 330 320 331 /** 321 332 * @ticket 34299 322 333 */