I have a personal website and I am trying to have an image and upon clicking, redirect to another website. My own website is for instance www.example.com, and I want to (upon clicking image) go to www.website.com. However, it goes to www.example.com/www.website.com and I do not want that. The code looks alright:
<a href="www.website.com">
<br><img src="website.png" alt="Avatar" class="webimage">
</a>
Any ideas?
2
Answers
This should work. You have to use http:// or https:// in front of the link. Otherwise it will redirect you to a local path.
Relative URL paths are any without a protocol, delimited by
//
. It could beginhttp://
,https://
, or even simply//
(though the delimiter without a stated protocol can apparently be used as an attack vector and so should be avoided.Relative URLs with
./
or no slash are appended to the current directory. Those with../
go up one to the parent directory. And those with a single slash (/
) go to the site root.Since you’re already at site root, that is your current directory, so the address is appended there.