Criizly
Criizly

Reputation: 41

Absolute vs Relative or Alternative HTML Links?

I'm currently building a website, i've got my base .html files for each of the top level sections, on each of those pages i've got a bunch of PHP include calls to various resources like the banner and navigation bar. Those PHP files link to resources stored on the server (using relative links).

The problem is, when I create a new forums folder, then include the banner and navigation bar using ../ to go back a folder, the resources that the banner includes doesn't work anymore because it's relative so looking in the wrong place.

My question is ... should make all the resource links absolute paths? - My instinct is saying no because each time they would have to do a DNS lookup, but I can't find an alternative. Does anyone know of any alternative ways to structure a site?

Upvotes: 0

Views: 124

Answers (1)

SLaks
SLaks

Reputation: 887997

My instinct is saying no because each time they would have to do a DNS lookup

Wrong.

Absolute paths do not involve a DNS lookup unless they're actually on a different domain.

URL formats have nothing to do with DNS lookups; instead, the browser will look up any hostname it doesn't know about. (DNS results are cached fairly aggressively)

Upvotes: 0

Related Questions