Should I use relative path for pages within the si

2019-08-13 04:14发布

I was just wondering what is the best way to define urls linking to pages within a domain name. For example, for domain www.example.com .. I can have links like

<a href="http://www.domain.com/test.html">test</a>

or

<a href="test.html">test</a>

One of the issues, which I came across was that while using templates .. if I use html template with relative links then I can't use the same template for directory www.example.com/directory2 as the common links won't work for that page .. neither the css nor javascripts files.

I either had to duplicate the template or set paths absolutely. I chose absolute paths. so template paths start with http://www.mydomain.com/ .. Does this cause any performance issue like multiple http requests, domain resolving, or any other? what is your suggesstion/comment on this?

Thanks.

7条回答
再贱就再见
2楼-- · 2019-08-13 04:55

Definitely use relative paths.

This will give you no less functionality, and will stop you having issues if your domain name changes, and will allow you to test on a different server, rather than in live....

查看更多
登录 后发表回答