Beware this content is over 8 years old and considered stale. It may no longer be accurate and/or reflect the understanding of the author but remains here for reference only. Please keep this in mind as you use this content.

I recently moved a clients distribution of Joomla! from a Windows 2003 enivornment running IIS6, a Microsoft Web Server. As some of you may know IIS and Joomla! do not play nice together, in particular all the SEF (Search Engine Friendly) and SEO (Search Engine Optimisation) settings do not work out of the box as they rely heavily on Apache’s mod_rewrite.

The mod_rewrite is an Apache function (Wikipedia refers to it as a software) that permits URL manipulation at the server-level, essentially modifiying a web URL’s appearance (URL rewriting).

The chance to move to a new server was a great opportunity to switch to a Linux/Apache hosting environment, not only as a chance to experiment with the additional features that would now be more readily accessbile but also as another learning experience.

One problem with migrating an installation from one hosting environment to another was that many of the URLs became invalid. Enabling the mod_rewrite support within Jooma! enabled me to remove the unsightly annoying index.php prefix that Joomla! uses as standard to all URLs.

1
artofsimplicity.co.uk/index.php/news/just-a-article-headline

By using the mod_rewrite the index.php would be dropped entirely making the URL [more? – debatable] SEF/SEO.

The result was that many of my clients articles and items on his website had already been cached by Twitter, Google News and other News Aggregators. As a solution I attempted to come up with a script for the default 404 page to allow users to try and get to the content that was originally being linked which would essentially be the same URL minus the index.php. The outcome of some research and lots of trial and error is a small script:

1
2
3
4
5
6
7
8
9
10
11
12
13
$brokenurl = $_SERVER["REQUEST_URI"];
$findme = 'index.php/';
$position = strpos($brokenurl, $findme);
if ($position === false) {
echo "The referring URL could not be determined as coming from the same domain."; // Insert other message or alternatively, nothing.
echo $_SERVER["REQUEST_URI"];
} else {
$p = '/\/index.php\//';
$r = '';
$o = preg_replace($p, $r, $brokenurl);
$newurl = "http://mydomain.com/$o";
echo "[$newurl]($newurl)";
}

It’s still being developed and it’s changed somewhat since posting but it gives you the general idea.

I began wondering if the benefits of SEF/SEO URLs are worth the time and effort required to get them operational. My first reaction would be a definitive “yes!”, but with the number of already cached URLs in major search engines and on various sites that now become largely invalid, was it all worth it? Well. “we shall see” - said the Zen Master.

Let me know what you think.