Getting the Current Page's Full URL on a Windows/IIS Server
When managing redirects on a Windows/IIS server, it's crucial to capture the full URL to ensure accuracy. However, this task can pose challenges, specifically when dealing with WordPress installations moved to new folder locations.
One challenge encountered is that both $_SERVER["REQUEST_URI"] and $_SERVER["PHP_SELF"] fail to provide the desired post title component of the URL. This is because IIS uses a different approach than Apache, which many recommendations assume.
To resolve this issue on an IIS server, the appropriate variable to utilize is $_SERVER['PATH_INFO']. This variable captures the requested portion of the URL, including the post title, in the format you require.
For instance, if your URL looks like this:
http:://www.example.com/OLD_FOLDER/index.php/post-title/
$_SERVER['PATH_INFO'] will return /post-title/.
Therefore, when configuring 301 redirects on a WordPress installation hosted on a Windows/IIS server, $_SERVER['PATH_INFO'] proves to be the reliable solution for retrieving the complete URL needed to achieve accurate redirects.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3