I always send all my requests to PHP via mod_rewrite and route using PHP. So all my links are absolute, i.e. /about/something
.
I usually write my links like so...
<a href="<?php echo BASE; ?>">home</a>
Where BASE
generally translates to /
or could be different depending on the base URL.
I remember giving <base href="<?php echo BASE; ?>" />
a go before, but I can't remember why I stopped using it (I think it was giving me headaches).
Are there problems with using this element?
The href attribute specifies the base URL for all relative URLs on a page.
No problem. But without the base tag, all of your relative links will break. URL rewrites are often necessary, because tweaking them can help your site's architecture and search engine visibility.
The base href is the URL prefix that should be preserved when generating and recognizing URLs.
Definition and Usage The <base> tag specifies the base URL and/or target for all relative URLs in a document. The <base> tag must have either an href or a target attribute present, or both. There can only be one single <base> element in a document, and it must be inside the <head> element.
The href of the base element had, in HTML 4.01, to be an absolute URI. See http://www.w3.org/TR/html4/struct/links.html#h-12.4.
Although some browsers are less strict I believe, I don't think all browsers are consistent in this, so <base href="/">
probably won't work cross-browser.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With