绝对与相对 URL [英] Absolute vs relative URLs

查看:41
本文介绍了绝对与相对 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道这两种 URL 的区别:相对 URL(用于图片、CSS 文件、JS 文件等)和绝对 URL.

I would like to know the differences between these two types of URLs: relative URLs (for pictures, CSS files, JS files, etc.) and absolute URLs.

另外,哪个更好用?

推荐答案

通常,使用相对 URL 被认为是最佳实践,这样您的网站就不会绑定到当前部署位置的基本 URL.例如,它将能够在本地主机以及您的公共域上工作,无需修改.

In general, it is considered best-practice to use relative URLs, so that your website will not be bound to the base URL of where it is currently deployed. For example, it will be able to work on localhost, as well as on your public domain, without modifications.

这篇关于绝对与相对 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆