我应该在网站上使用相对网址还是绝对网址? [英] Should I use relative or absolute url on my website?
问题描述
如果我不打算移动网站,那么为什么我应该使用绝对URL的相对地址是有充分的理由?
If I'm not moving my site around, any good reason for why I should use absolute URL's over relative?
推荐答案
无论您将内容从一个文件夹移到另一个文件夹,绝对URL都可以使用,但是每种语言都有一种以一种或另一种方式引用BASE URL的方法.
Absolute URL's will work no matter if you move the content from folder to folder, however each language will have a way to reference a BASE URL in one way or another.
例如,如果您在index.html上具有"test/1.html"作为URL,它将重定向到/test/1.html,但是,如果将该链接复制到/dom/index.html,它将重定向到/dom/test/1.html
For example if you have "test/1.html" as a URL on index.html it will redirect to /test/1.html however if you copy that link to /dom/index.html it will redirect to /dom/test/1.html
最佳做法是先使用基本网址,然后再使用相对网址,例如{BASE URL}/test/1.html
It would be best practice to use the base URL and then the relative URL e.g. {BASE URL}/test/1.html
这篇关于我应该在网站上使用相对网址还是绝对网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!