如何在Windows / IIS服务器上获取当前页面的完整URL? [英] How can I get the current page's full URL on a Windows/IIS server?
问题描述
我将 WordPress 安装移至Windows / IIS 服务器。我在PHP中设置301重定向,但它似乎没有工作。我的帖子网址格式如下:
I moved a WordPress installation to a new folder on a Windows/IIS server. I'm setting up 301 redirects in PHP, but it doesn't seem to be working. My post URLs have the following format:
http:://www.example.com/OLD_FOLDER/index.php/post-title/
我无法弄清楚如何抓住 / post-title /
网址的一部分。
I can't figure out how to grab the /post-title/
part of the URL.
$ _ SERVER [REQUEST_URI]
- 每个人似乎都建议 - 返回一个空字符串。 $ _ SERVER [PHP_SELF]
刚刚返回 index.php
。为什么会这样,我该如何解决?
$_SERVER["REQUEST_URI"]
- which everyone seems to recommend - is returning an empty string. $_SERVER["PHP_SELF"]
is just returning index.php
. Why is this, and how can I fix it?
推荐答案
也许,因为你在IIS下,
Maybe, because you are under IIS,
$_SERVER['PATH_INFO']
是你想要的,基于你用来解释的URL。
is what you want, based on the URLs you used to explain.
对于Apache,你要使用 $ _ SERVER [' REQUEST_URI']
。
For Apache, you'd use $_SERVER['REQUEST_URI']
.
这篇关于如何在Windows / IIS服务器上获取当前页面的完整URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!