How to make relative links on the pages?
By default, Joomla! inserts into a page absolute (”http://site.com/page”), instead of relative (”/page”) links. It has an advantage—for example if someone will copy the text of your pages all links still will point to your site. But authors of some sites wish, that on their site all links were relative since it can noticeably reduce the size of page.
For this purpose, as well as in the previous note (Why Homepage is “index.php?option=com_frontpage&Itemid=1″?), it is necessary to edit function “sefRelToAbs” in a file “/includes/sef.php” since the outputting of practically all links in Joomla! is fulfilled through this function.
We change (approximately 520-th line)
return $mosConfig_live_site . '/' . $string . $fragment;
to
return '/' . $string . $fragment;
and (approximately 555-th line)
$string = $mosConfig_live_site . '/' . $string;
to
$string = '/' . $string;
June 11th, 2007 at 5:56 am
May be it’ll be interesting to anyone:
Comment on problem with rss export after applying this patch.
July 13th, 2007 at 5:02 am
Hiya
Annoyingly I am having to retype this because your form did not like my @{at} approach.
Regardless, we seem to have the opposite problem. Our ’spider’ reports back lots of 404 errors from relative links. Is there a way to make relative links absolute?
for example
404: org_uri is http://www.rerere.uk/friends-alumni/gazette-and-newsletter/images/alumni/summernews2006.pdf
because the code should in fact point to
http://www.rerere.uk/images/alumni/summernews2006.pdf
Any help advice would be appreciated…
Cheers
Chris
July 13th, 2007 at 5:14 am
Most likely your link looks like “images/alumni/summernews2006.pdf” instead of “/images/alumni/summernews2006.pdf”.
July 13th, 2007 at 10:17 am
okay - i cannot change the href to either /xxx or the full link - any suggsetions?
July 13th, 2007 at 10:58 am
Then try to add
into the head-section of your template (index.php). It is strange that this line is lacking in your page.
(see page source of http://wadham.ox.ac.uk/friends-alumni/gazette-and-newsletter/wadham-gazette-newsletter.html
)
September 9th, 2007 at 12:28 pm
/” /> is more proper for Joomla index.
September 9th, 2007 at 12:31 pm
…well. that didn’t work well. Sorry I do not know the proper syntax to style for code on this blog. What I meant to add was that for base href= in a Joomla template, it would be more proper to use $mosConfig_live_site
September 9th, 2007 at 2:57 pm
PG:
You are right. In the general case it is more proper to write