HTML urls - how to add to an existing url

This is a stupidly simple question, but after a long search I have not yet given any results.

My question is the following.

I have a webpage with the address http://domain.com/mypage/ladeda/

I have a link on this page.

<a href="/1/">Page 1</a> 

This link sends me to http://domain.com/1/

 <a href="1/">Page 1</a> 

This link will lead me to http://domain.com/mypage/1/

How do I get my link to take me to http://domain.com/mypage/ladeda/1/

without having to extract all aspects of the page url and put them in href.

Many thanks

+8
url append hyperlink
source share
2 answers
 <base href="/mypage/ladeda/" /> ... <a href="1/">(goes to http://domain.com/mypage/ladeda/1/)</a> 

Via the <base> element.


But!
<a href="1/">Page 1</a> should go to http://domain.com/mypage/ladeda/1/ already provided that (a) you are no longer using the <base> element and ( b) the current resource is indeed http://domain.com/mypage/ladeda/ (with a trailing slash).

+8
source share
 <a href="/mypage/ladeda/1">Page 1</a> 

If the current page is not in the same directory (real or virtual) as the landing page, you will need to specify the full path. Either relative or absolute. There is no way around this.

0
source share

All Articles