执行此站点重定向的最佳方法是什么
What is the best way to do this site redirection
有一个网站,我们在其中指向 "www.example1.com" 的一些链接。
最近 "www.example1.com" 更改为 "www.example2.com"。
现在如果我们访问 "www.example1.com" 它会自动重定向 "www.example2.com".
在"www.example.com"
中它仍然指向"www.example1.com"
。
它现在的工作情况如何...
www.example.com->www.example.com->www.example1.com->www.example2.com.
在我们的网站上,所有链接都是硬编码的。
问题 ?
最好的方法是什么?
继续保持这样或需要更新所有硬编码值。
问题是:将来如果我们再次更新这个url,我们需要再次更新代码
请帮我提点建议。
来自the spec
10.3.2 301 Moved Permanently
The requested resource has been assigned a new permanent URI and any
future references to this resource SHOULD use one of the returned
URIs. Clients with link editing capabilities ought to automatically
re-link references to the Request-URI to one or more of the new
references returned by the server, where possible. This response is
cacheable unless indicated otherwise.
所以是的,如果您要永久重定向 URL,那么您应该更新 link 以指向新位置。
实际上,这将使访问 link 的浏览器不必在数字 kafkaesque 噩梦中被告知离开并在其他地方重复请求文档。
有一个网站,我们在其中指向 "www.example1.com" 的一些链接。
最近 "www.example1.com" 更改为 "www.example2.com"。
现在如果我们访问 "www.example1.com" 它会自动重定向 "www.example2.com".
在"www.example.com"
中它仍然指向"www.example1.com"
。
它现在的工作情况如何...
www.example.com->www.example.com->www.example1.com->www.example2.com.
在我们的网站上,所有链接都是硬编码的。
问题 ?
最好的方法是什么?
继续保持这样或需要更新所有硬编码值。
问题是:将来如果我们再次更新这个url,我们需要再次更新代码
请帮我提点建议。
来自the spec
10.3.2 301 Moved Permanently
The requested resource has been assigned a new permanent URI and any future references to this resource SHOULD use one of the returned URIs. Clients with link editing capabilities ought to automatically re-link references to the Request-URI to one or more of the new references returned by the server, where possible. This response is cacheable unless indicated otherwise.
所以是的,如果您要永久重定向 URL,那么您应该更新 link 以指向新位置。
实际上,这将使访问 link 的浏览器不必在数字 kafkaesque 噩梦中被告知离开并在其他地方重复请求文档。