Reputation: 546
This seems like a simple question but it's baffling me. Let's say my domain is: bar.com and my subdomain is foo.bar.com.
If I'm on foo.bar.com/1/2 and I go back a directory through a link with a relative path (href="../") it will take me to foo.bar.com, not foo.bar.com/1 as I'd expect it to. Why is this? How do I get to foo.bar.com/1 with a relative path?
Side question: If foo.bar.com is masking another directory (let's say bar.com/foo, and I go to href="/", will that take me to the root of the entire domain (bar.com) or just to the root of the subdomain (foo.bar.com)?
Upvotes: 1
Views: 952
Reputation: 1110
If the current page is http://foo.bar.com/1/2
, browser thinks 2
is a document under the directory 1
. So if you have ../
, it goes to its parent directory, which is the root directory. If you want to link to http://foo.bar.com/1/
, you can use href=./
.
I don't quite understand your side question. Generally if the URL displayed in browser is bar.com/foo
, then href="/"
takes users to bar.com/
; if the URL displayed in browser is foo.bar.com/
, then href="/"
takes users to foo.bar.com/
Upvotes: 3