基于永久id的Web HTTP/HTTPS超链接方案,有多少种实现方式?

发布于 2024-09-10 01:43:32 字数 842 浏览 4 评论 0原文

背景:

假设我有一个托管在 http://www.example.com< 上的网站/a> 并且该网站有很多绝对内部链接。发生了一些事情,需要我将整个网站移至http://www.example.net< /a> 所有其他内容保持不变。

显然,我可以进行全局搜索并替换网站代码来解决此问题,但我想知道有多少种方法可以创建一个永久链接方案,无论我在哪个网站,都永远不会中断移动到,只要相对路径相同即可。

注意:将 example.com 和 example.net 替换为两个完全不同的网络托管公司的名称。它们仅用于不提供免费广告的通用名称。

问题

有多少种不同的方式来支持永久超链接,例如:

http://some-aribitrary-string.com/some/path/here/page.htm

这样:

  • some-任意字符串代表一个唯一的字符串,永远不必更改
  • some-任意字符串解析为 DNS 条目或者我的代码在任何给定时间托管的任何机器的 IP 地址,
  • 如果我必须更改服务器,我只需在一处更新此信息(而不必执行全局字符串搜索和替换
  • )要使用此方案,我不必访问 DNS 记录

Background:

Suppose I have a website that is hosted on http://www.example.com and the site has a lot of absolute internal links. Something happens that requires me to move the entire website to http://www.example.net with all other things remaining the same.

Obviously, I can do a global search and replace on the website code to fix this, but what I am wondering is how many ways can I create a permanent linking scheme that will never break regardless of what site I move to, as long as the relative paths are the same.

NOTE: replace example.com and example.net with the names of two totally different web-hosting companies. They were just used for generic names that do not provide free advertising.

Question:

How many different ways are there to support permanent hyperlinks such as:

http://some-aribitrary-string.com/some/path/here/page.htm

Such that:

  • some-arbitrary-string represents a unique string that will never have to change
  • some-arbitrary-string resolves to the DNS entry or IP address of whatever machine my code happens to be hosted on at any given time
  • if and when I have to change servers, I only have to update this information in one place (instead of having to do global string search and replace)
  • in order to use this scheme I do not have to have access to DNS records

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

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

发布评论

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

评论(1

乖不如嘢 2024-09-17 01:43:32

重写应该足够了:

RewriteEngine On
RewriteRule ^(.*)$ http://some-arbitrary-string.com/$0 [L]

您还可以使用 [P][R=301] 通过内部代理路由请求或正确重定向它们。

A Rewrite should be enough:

RewriteEngine On
RewriteRule ^(.*)$ http://some-arbitrary-string.com/$0 [L]

You could additionally use [P] or [R=301] to route requests through an internal proxy or properly redirect them.

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