Changing relative url's to absolute sitewide

Support help forum dedicated to free and commerical templates for Joomla 3 and 2.5 version.
GK User
Mon Aug 27, 2012 9:18 pm
Is it possible? I am working with an SEO specialist who specifically wants absolute URL's for the client's site. I am not sure how to do this without breaking something. Does anyone have any ideas :?:

Thanks.
B
User avatar
Junior Boarder

GK User
Mon Aug 27, 2012 10:00 pm
Do you want to add the absolute URLs on the website menu or on the whole page (articles, modules etc.)?
User avatar
Administrator

GK User
Mon Aug 27, 2012 10:16 pm
dziudek wrote:Do you want to add the absolute URLs on the website menu or on the whole page (articles, modules etc.)?


Hey dziudek!
Well, actually anywhere I can. The client wants it everywhere.
Also changing the existing relative links to absolute as well.

Is this all possible?


B
User avatar
Junior Boarder

GK User
Tue Aug 28, 2012 6:57 am
As I've checked there is no easy way for it, because it will need probably rewriting a lot of parts of Joomla! code or using some special plugins - but I haven't found anything like this :/
User avatar
Administrator

GK User
Tue Aug 28, 2012 10:40 am
dziudek wrote:As I've checked there is no easy way for it, because it will need probably rewriting a lot of parts of Joomla! code or using some special plugins - but I haven't found anything like this :/


Crap. Is there any direction you could point me in? I have been researching this everywhere and can't find a solution, idea or anyone who has had the same problem of wanting to convert relative paths to absolute paths sitewide. ANY suggestion would help. :(

Thanks

B
User avatar
Junior Boarder

GK User
Tue Aug 28, 2012 11:09 am
I've a small idea, maybe it will help you - please open Joomla! index.php file (the main joomla index.php file) and please change the last lines:

Code: Select all
// Return the response.
echo $app;


to:

Code: Select all
// Return the response.
echo str_replace('<a href="/', '<a href="' . str_replace(JURI::root(true), '', JURI::root()), $app);


It should replace all relative links to the absolute paths (but unfortunately only when the link starts with
Code: Select all
<a href="
User avatar
Administrator

GK User
Tue Aug 28, 2012 1:46 pm
:woohoo: HOLY CRAP! It worked! :woohoo:
Your small idea fixed a very BIG problem.
This is a load off my chest. Thank you so much.

B
User avatar
Junior Boarder

GK User
Tue Aug 28, 2012 2:06 pm
Good to know :) Please check if all anchor elements are correct, but probably it will be, because the script changes only relative links starting with slash.
User avatar
Administrator


cron
Remember me
Register New Account
If you are old Gavick user, click HERE for steps to retrieve your account.