查找文档 URL 的 SSI 环境变量

发布于 2024-12-09 20:30:20 字数 737 浏览 8 评论 0原文

我正在寻找一个可以返回文档 URL 的 SSI 环境变量...

http://www.mySite.com/path/myPage.html

现在,我正在使用这些其他环境变量将其拼凑在一起...

<!--#echo var="SERVER_NAME" -->

给出以下内容:http://www.mySite.com,并且...

<!--#echo var="DOCUMENT_URI" -->

给出:/path/myPage.html

所以我把它们放在一起,就像这样......

http://<!--#echo var="SERVER_NAME" --><!--#echo var="DOCUMENT_URI" -->

而且效果很好。

两个问题:

1) 完整文档 URL 是否有一个 SSI 环境变量?我已经寻找了一段时间但似乎找不到。

2)如果没有,有人可以解释为什么吗?有一个名为 HTTP_REFERER 的方法可以返回引用者的完整 URL,那么为什么不返回当前位置的完整 URL(例如 DOCUMENT_URL)呢?

I'm looking for an SSI Environment Variable that can return the Document URL...

http://www.mySite.com/path/myPage.html

Right now, I'm cobbling it together using these other environment variables...

<!--#echo var="SERVER_NAME" -->

gives this: http://www.mySite.com, and...

<!--#echo var="DOCUMENT_URI" -->

gives this: /path/myPage.html.

So I'm putting them both together, like this...

http://<!--#echo var="SERVER_NAME" --><!--#echo var="DOCUMENT_URI" -->

And it works just fine.

Two questions:

1) Is there a single SSI Environment Variable for the full Document URL? I've been searching for a while but cannot seem to find.

2) If not, can somebody explain why? There is one called HTTP_REFERER that returns the full URL of the referer, so why not one that returns the full URL of the current location, something like a DOCUMENT_URL?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酒中人 2024-12-16 20:30:20

1)不,没有。您可以通过所有环境值的简单转储来检查这一点:

<pre>
<!--#printenv -->
</pre>

2)为什么?我不确定,也许是因为将其放在单个变量中是多余的,您可以像以前一样将其拼凑在一起。事实上,您可能还想做某些事情,例如忽略服务器协议(HTTP 或 HTTPS)或使用不同的端口,或任何其他原因。

希望有帮助

1) No, there isn't. You can check this by a simple dump of all environment values:

<pre>
<!--#printenv -->
</pre>

2) Why? I'm not sure, perhaps because it would be redundant to have that in a single variable where you can cobble it together as you did. That and the fact that you might want to also do certain things like ignore the server protocol (HTTP or HTTPS) or use a different port, or any number of other reasons.

Hope that helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文