Work Inquiries
contact@aysa.ai
Ph: +40722237373
Back

Relative URL

What is a Relative URL?

A relative URL specifies the location of a resource relative to the current page’s URL, rather than providing a full address. It omits the protocol (http:// or https://) and the domain name, focusing instead on the path relative to the page’s current location.

For example, if you are on the page:

https://adverlink.net/seo/glossary/relative-url

and it contains the following link:

<a href="best-practices">best practices</a>

This relative URL will resolve to:

https://adverlink.net/seo/glossary/relative-url/best-practices

Understanding a Directory

Relative URLs can behave differently based on whether the current page URL ends with a trailing slash.

With a Trailing Slash:

For the URL:

https://adverlink.net/seo/glossary/relative-url

The link:

<a href="best-practices">best practices</a>

Points to:

https://adverlink.net/seo/glossary/relative-url/best-practices

Without a Trailing Slash:

For the URL:

https://adverlink.net/seo/glossary/relative-url

The same link:

<a href="best-practices">best practices</a>

Points to:

https://adverlink.net/seo/glossary/best-practices

This difference occurs because URLs with trailing slashes are interpreted as directories, while those without are treated as files within the current directory.

You can also use ./ to signify the current directory:

<a href="./best-practices">best practices</a>

This also points to:

https://adverlink.net/seo/glossary/relative-url/best-practices

Root-Relative Path

A root-relative URL begins with a leading slash, which means it is relative to the root of the domain:

<a href="/best-practices">best practices</a>

This points to:

https://adverlink.net/best-practices

One Level Up

To link to a directory one level up from the current one, use the ../ prefix:

<a href="../best-practices">best practices</a>

For the URL:

https://adverlink.net/seo/glossary/relative-url

This link points to:

https://adverlink.net/seo/best-practices

Relative vs Absolute URLs for SEO

In terms of SEO, both relative and absolute URLs are generally treated equally. However, it is advisable to use absolute URLs in rel="canonical" and hreflang tags to prevent potential errors and ensure consistency across various contexts.

  • Relative URLs: Useful for internal linking within a website, especially for frequent updates or when working in different environments.
  • Absolute URLs: Preferred for canonical and hreflang tags to avoid confusion and ensure clarity regarding the resource’s location.
admin
admin
https://adverlink.net

This website stores cookies on your computer. Cookie Policy