6

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?

3 Answers 3

3

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.

Sign up to request clarification or add additional context in comments.

Comments

3

I always use base href for the same reason; I use mod_rewrite to make the url into a query string and I don't want to use absolute urls all over the place. So I put one base href at the top. Never had any real issues with it.

2 Comments

Have you tried doing a javascript "location.href" to a relative url in a subfolder, using base href, in IE? Example: if your base href is "site.com" and your javascript onclick is "window.location.href='folder/targetpage.html';return false;" - in IE this won't work properly if you're already in that subfolder. Do you have a workaround for this?
Never noticed this; so obviously don't really have a workaround.
0

OpenCart uses it, Magento 1.7+ does not, Drupal 6 does not. I have run into one custom base href implementation in the past and it seems to make maintenance on the project harder, but that's just my opinion.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.