Reputation: 2783
I have a URL www.foo.com/bar/hello/world
Can I use href=
in such as way:
<a href = "/hello/world"> LinkText </a>
In other words, because of the versioning repository I use for work, only the sublink /hello/world
of the final URL will the same when I push the site live.
Upvotes: 1
Views: 305
Reputation: 81
Only if the source code is located in 'http://www.foo.com/bar' and then it needs to be going to a valid file extension to execute an action:
<a href="/hello/world.html">LinksText</a>
Upvotes: 1
Reputation: 1603
However, in href
, you can either use an absolute URL, such as https://www.foo.com/bar.html
or, relative, something like /bar.html
, where /
refers to the webserver root (but not webserver's system root), or, you can use bar.html
which points to a file in the same directory level.
Basically you want to have a /hello/world
link, it will point to www.foo.com/hello/world
.
If you want it www.foo.com/hello/world
to point at www.foo.com/bar/hello/world
, you can either rewrite the URL on the server, or, redirect the users to www.foo.com/bar/hello/world
For URL rewriting, see your appropriate webserver docs
Upvotes: 2