Reputation: 123
I'm in the following directory on my server:
Components are in .phtml files but the extension is removed by htaccess rules.
Now I want to go to another .phtml file but then I have to write this:
<a href="../other-page/"></a>
I noticed I can also just do this:
<a href="/other-page/"></a>
But then it won't go to http://example.nl/cms/other-page/ as I want, but to http://example.nl/other-page/
How can I change the document root to "cms"
so that I only have to use a single "/"
?
Upvotes: 4
Views: 1770
Reputation: 595
For absolute URLs, leading with a slash (/
), the base attribute does not work.
Here is what you need for relative URLs. You need to set the meta tag basedir:
<html>
<head>
<base href="http://example.nl/cms/">
</head>
<body>
<a href="other-page">click me</a>
</body>
</html>
And then the browser knows that by other-page
you want to link to /cms/other-page
.
This is supported in all browsers as you can see.
Upvotes: 4