Using Forward Slash Instead of a Hyphen in K2’s sh404 Links

Yes – we know – the title of this post couldn’t be more odd, but here’s the scenario:

  • We were migrating a large website from Joomla 1.5 to Joomla 2.5.
  • Nearly all of the content of the migrated website was created in K2 and the website was using sh404.
  • The links on the old Joomla 1.5 website had the following format: http://www.ourclientjoomlawebsite.com/[article-id]/[article-alias].html.
  • In the migrated Joomla 2.5 website, the links had the following format http://www.ourclientjoomlawebsite.com/[article-id][article-alias].html.

As you can see from the above, the links had a dash between the article id and the article alias in Joomla 2.5, however, in Joomla 1.5, they had a forward slash.

Now we have tried everything to change that dash into a forward slash – we changed every value in K2 sh404’s settings (which can be accessed in K2’s configuration from the K2 component, and not from sh404) – but nothing worked. The dash was always a dash…

So we checked K2’s code to see if the dash was hard-coded somewhere, and, to our surprise it was: Here’s line 181 of the file com_k2.php located under the components/com_k2/sef_ext directory:

$title[] = $row->id.'-'.$row->$sh404SefTitleAlias;

It was obvious that the dash was hard coded in the code…

So, what did we do to fix the problem?

We just changed the above line (in the file com_k2.php) to the following…

$title[] = $row->id.'/'.$row->$sh404SefTitleAlias;

… and K2 was intelligent enough to handle the rest! We purged the URLs in sh404 and we re-visited the website and all the links were now OK! Not too bad for a one-character-change in the code, huh?

Now, in case you have a problem with K2’s links in sh404, or just any other problem on your Joomla website, then you can rest assured that we can fix it for you. We are professional, we are hard working, we are fast, we know Joomla inside out, and we won’t charge you much. Come on, what are you waiting for, contact us!

One Response to “Using Forward Slash Instead of a Hyphen in K2’s sh404 Links”
  1. Pingback by Top 8 Reasons Why You Should Use K2 | itoctopus — April 15, 2013 @ 7:47 am

    […] one of the most used and one of the most prominent Joomla extensions. Luckily, K2 has native (and easily modifiable) support for sh404 (it’s interesting to note that it’s K2 that supports sh404, and not […]

Leave a comment