Subject: Converting Site-Relative Links to Absolute Paths

Posted on: 13/05/13 01:32pm
By: masodo

I have really enjoyed my Geeklog adventure thus far and thought I would share my latest success in running (for the record I am running GL Version 1.8.1)

First let me say that I have set-up a WordPress site and a Blogger site so that I might participate with all those many bloggers utilizing those platforms. I use my pages from those services to advertise and link to my Geeklog site. Recently I created a Feedburner RSS Feed from my Geeklog feed so that I could utilize the animated Feedburner widget on those "other" blog pages. I have also added the Feedburner "Subscribe To My Site Via Email" Service link to my Geeklog page.

I was not too far into this endeavor before I noticed there was a problem with how my feed was rendering on both the Feedburner feed page and in the Updates sent to email subscribers. The problem was that for the most-part I use site-relative linking which means that all image source links and local page links were broken in the syndicated versions of the posts. Of course the fix for this is to replace all site-relative links with their absolute path counterparts.

So from now on I will be using full paths when I create my posts but as for all those previously published posts that use the site-relative links I decided to craft a MySQL statement to convert all the links in the gl_stories table to absolute paths in one "fell swoop."

Of course the very first thing I did was back-up my entire database. I then logged-in to phpmyadmin and exported my gl_stories table to a file so that even my back-up had a back-up.

The SQL statement that I ran against my Database was based on the following syntax:
PHP Formatted Code
update [table_name] set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]');

In my case the specific commands were as follows:

PHP Formatted Code
update gl_stories set introtext = replace(introtext,'="/','="');

PHP Formatted Code

update gl_stories set bodytext = replace(bodytext,'="/','="');

And that - as they say - was that! Mission accomplished.

Re: Converting Site-Relative Links to Absolute Paths

Posted on: 16/05/13 12:26am
By: suprsidr

So you'll have to run that query every time you create a new story? Personally I'd update the RSS feed generator to include full urls.


Re: Converting Site-Relative Links to Absolute Paths

Posted on: 22/07/13 07:28am
By: masodo

The plan is to always use full URLs in my posts from here on out. This maneuver was to get all previous entries up-to-speed. True, I should probably look into altering the RSS Generator to rewrite site relative paths to full paths. However, I found this to be an immediate fix, well within my comfort zone. If anyone has worked out the suggested RSS generator alteration I sure would be grateful to learn the details. Big Grin

Geeklog - Forum