如何知道当URL被重写并打开另一个页面时,在浏览器中看到的当前URL是什么


How to know what is the current URL seen in browser when the URL is rewritten and opening an other page?

示例:

如果我写http://www.mydomain.com/folder/documents/page/index.php?id=something,并且我重写页面,让它在后台加载http://www.mydomain.com/index.php,索引中的 PHP 代码.php怎么知道前一页的路径和查询是folder/documents/page/index.php?id=something的(使用查询)?

使用$_SERVER['PHP_SELF']$_SERVER['QUERY_STRING']可以完成这项工作,还是他们会给我重写的值?

否则,有没有其他方法可以知道 URL 栏中的内容?实际上,我需要http://www.mydomain.com/index.php做的事情是加载位于其他站点上的页面,但具有以前的URL结尾。我需要一种方法来实现这一点,并在PHP代码中知道当前页面的URL是什么。当前页面打开并被客户端看到,就像http://www.mydomain.com/folder/documents/page/index.php?id=something但运行脚本http://www.mydomain.com/index.php

感谢您的帮助,我很快就有截止日期了,但我还没有找到实现这一目标的方法。我搜索了几个小时,没有找到一个合理的答案。

使用 $_SERVER['REQUEST_URI'] OR $_SERVER['REDIRECT_URL'] 返回重写地址。