Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML Urls - how to append to the existing url

This is a stupidly easy question, however after searching for a long time I have yet to yield any results.

My question is as follows.

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

I have a link on this page.

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

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

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

That link takes 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 the aspects of the page url and put them within the href.

Many Thanks

like image 405
Thomas Clowes Avatar asked Sep 01 '11 14:09

Thomas Clowes


People also ask

How do you append a link in HTML?

Complete HTML/CSS Course 2022 To make a hyperlink in an HTML page, use the <a> and </a> tags, which are the tags used to define the links.

How do you append a URL?

Paste the URL parameter to the end of the URL in the text editor. Copy the full URL with the appended URL parameter. Post the URL to the desired location. The location is the place from which you would like applicants to be able to see and click the link.

Why does href append to current URL?

Anchor URL Therefore ensure that your intended external URL does not contain a number sign, or that you have not mistakenly included one in your code. By default, anchor links with no preceding URL value will result in the hyperlink being appended to the current URL.

What is HREF in HTML?

The href attribute specifies the URL of the page the link goes to. If the href attribute is not present, the <a> tag will not be a hyperlink.


1 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 take you to http://domain.com/mypage/ladeda/1/ already provided that (a) you don't use a <base> element already and (b) the current resource is really http://domain.com/mypage/ladeda/ (with a trailing slash).

like image 109
jensgram Avatar answered Sep 30 '22 08:09

jensgram