Terry Li
Terry Li

Reputation: 17268

Absolute URL and relative URL

Here's the homepage of Stony Brook University: http://www.stonybrook.edu/

There's a link whose anchor text is "Academics" on the homepage. By checking the source code of the page, I find that the "Academics" link has a relative URL: academics.shtml.

To my surprise, the absolute URL: http://www.stonybrook.edu/academics.shtml isn't that of the "Academics" link. In fact, it does not exist at all. The correct absolute URL for the "Academics" link is: http://www.stonybrook.edu/sb/academics.shtml

I'm confused where the path /sb/ comes from. I'm asking about it because I'm trying to obtain the absolute URL based on the base URL and relative URL using the Java URL class.

Upvotes: 0

Views: 184

Answers (2)

Shiva Sena
Shiva Sena

Reputation: 1

you can do this by using following markup

<base href="http://www.stonybrook.edu/sb/" />

Additionally if you need further information regarding absolute vs relative i have found good page with example . https://downloadgenerators.com/question/what-is-the-major-difference-between-absolute-url-and-relative-url I hope this will help you.

Upvotes: 0

Oliver Charlesworth
Oliver Charlesworth

Reputation: 272467

Also from the source:

<base href="http://www.stonybrook.edu/sb/" />

Upvotes: 4

Related Questions