Skip to content

Commit b2f01f3

Browse files
committed
Use UNENCODED_URL instead of REQUEST_URI when UNENCODED_URL is set
In environments using URL Rewrite in IIS, since `REQUEST_URI` may be set to an invalid URL that has been URL encoded by URL Rewrite, use `UNENCODED_URL`, which sets the request URL as is.
1 parent 1c2eb30 commit b2f01f3

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

no.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@
2626
$backend_url = "https://myapp.backend.com:3000/";
2727
$backend_info = parse_url($backend_url);
2828
$host = $_SERVER['HTTP_HOST'];
29-
$request_uri = $_SERVER['REQUEST_URI'];
3029
$uri_rel = "subdir/no.php"; # URI to this file relative to public_html
3130

31+
// When using IIS with URL Rewrite, URL encoding may not work as expected, so use `UNENCODED_URL` instead.
32+
// https://learn.microsoft.com/en-us/iis/extensions/url-rewrite-module/url-rewrite-module-configuration-reference#preserving-original-url
33+
$request_uri = isset($_SERVER['UNENCODED_URL']) ? $_SERVER['UNENCODED_URL'] : $_SERVER['REQUEST_URI'];
34+
3235
$request_includes_nophp_uri = true;
3336
if ( $request_includes_nophp_uri == false) {
3437
$request_uri = str_replace( $uri_rel, "/", $request_uri );

0 commit comments

Comments
 (0)