Forum Moderators: open
<base href="http://www.example.com/">to establish the base url of the site.
Our site uses internal a href links like this:
<a href="/page1.htm">
Rather than the full url.
We used to use a base ref on each page that was:
<base href="http://www.example.com/">
But recently decided to specify the exact url of each page in the base ref:
<base href="http://www.example.com/page2.htm">
So every page has a different base ref url.
Is this okay or will it cause confusion or conflict to some bots?
I did have a look at WebmasterWorld but couldn't get a definite answer.
If it's wrong we'll change it back.
[edited by: encyclo at 11:24 pm (utc) on Aug. 5, 2007]
I used W3c's own link checker and it found no broken links, handling the base ref properly, as did another online site-wide link checker, however, I just tried an online site analysis tool at random.
It is on G's first page of results.
And it (falsely) claimed all my internal links were broken.
They work fine, but the analysis tool simply added the internal link to the base ref url thus:
http://www.example.com/mainpage.htm/page.2.htm
Resulting in a 404.
So there's one clear example of a bot getting confused by this. The first one I've noticed.
NB: I use the full page url in the base href and root-relative internal links.
PS: thebear: Using CSS and ditching tables dramatically improved our load times. (Just scored 10 out 10). Also we lifted the page text to the top of the html file so it gets looked at first by the bots.
But I understand what you mean about multiple external css files and overdoing the styling.
You clearly have more confidence in SEs than I do. :)
However if they get that part totally wrong they would be out of business very quickly.
Besides html element striping is fairly straight forward.
Like I said after many tens of thousands of pages with many links I haven't seen any fallout.
I also would not add to the complexity of what has to be done to determine what that href actually points to.
The other thing is that the bot doesn't do the indexing or ranking.
I don't use full urls on images just in case someone puts the page in a frame (even though I have a pop out of frames script on every page) so if the page does manage to get copied the images won't work but the URLS to my site will work.
Being in a test environment I default to localhost, you could change it to your local IP of course.
The second part matches your domain name (doesn't need to be exactly your domain name).
The third part assumes you're running your local environment but are showing your test work to a friend via your IP address.
Also if you're using HTML instead of XHTML you will want to remove the trailing slash on the second to last line.
Hope some people find this handy! :)
- John
if ($_SERVER['HTTP_HOST'] == "localhost")
{
$path = 'http://localhost/this_projects_path/';
}
else if ($_SERVER['HTTP_HOST'] == "yoursite")
{
$path = 'http://www.yoursite.com/';
}
else
{
$path = 'http://'.$_SERVER['SERVER_ADDR'].'/this_projects_path/';
}echo '<base href="';
echo $path;
echo '" />' . "\n";