Malia McLaughlin
Malia McLaughlin

Reputation: 11

Absolute Links Resolving to Current Domain

My HTML code has never behaved this way before! I have looked around the internet and here and I can't find an answer to this.

The problem is simple: external links do not go to external webpages and instead become internal links

For example: If I'm on http://www.domain.com where I have an external link

<a href="http://www.nasa.gov">National Aeronautics and Space Administration</a>

When the link is clicked, instead of going to www.nasa.gov or opening a new window for nasa.gov, it goes to http://www.Domain.com/www.nasa.gov

Why is it doing this?

Upvotes: 1

Views: 175

Answers (1)

worldofjr
worldofjr

Reputation: 3886

I am certain that your address is missing a / in your actual code.

<a href="http:/www.nasa.gov/">Test</a>

would resolve to http://www.domain.com/www.nasa.gov/. Note only one slash after the protocol.

Two slashes // indicate your address is absolute (external) whilst one slash / tells the browser to go to the root directory of the current site to find the address (relative). This is because you could change protocol (such as https:) and then give a relative address (such as /path/to/content.html).

Hope this helps.

Upvotes: 2

Related Questions