This website uses cookies to improve your experience and deliver relevant information.

We build solid foundations

Our holistic, strategic approach to design, development and marketing means we help you build a strong, sustainable digital presence


on Tuesday, 29 November 2011

Removing index.php from existing Joomla! SEF URL's

So you set up your Joomla! site, made it live, and a few weeks/months/years later realised that you'd forgotten to enable the HTAccess file for SEF URL's. The end result being that rather than having a nice Search Engine (and user) friendly URL like /category/Blogs/post/, you instead have /index.php/category/Blogs/post/.

You could just enable the HTAccess file, but all the old URL's will return a 404. Not great if your site has already been indexed by search engines, even less great if you've got lots of inbound links on other sites. 

It's actually incredibly simple to resolve, and in this post I'll be showing you the two easy steps you need to take to configure your site to redirect the old /index.php/* URLs to the nice SEF ones you want.

The first step is simple, we need to enable the HTAccess file (assuming you haven't already). In the root of your Joomla! site is a file called htaccess.txt, rename it to .htaccess

Second step: We need to add a mod_Rewrite rule to catch the old-style links. Open .htaccess in a text editor and find the line "RewriteEngine On". Immediately below add the following (lines with a hash are comments, you can skip these if needed)

# Make sure the requested URL isn't a file or directory
# Why you'd create a directory called index.php, but best to be sure
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

# Use a reg-Ex to find URL's where index.php is followed by something.
# If so, create a redirect to whatever followed the slash
RewriteRule ^index.php/(.*)$ /$1 [R=301]

Don't forget to save the file!

Now if you visit http://yoursite/index.php/category/Blogs/post/ you should be redirected to http//yoursite/category/Blogs/post/. Because you're sending a 301 (Permanently moved), the search engines should update their indexes as well.

It's something people encounter a lot, but as you can see it's incredibly easy to resolve.


We're specialists in Content Management Systems Want to work with the experts?

Virya Group provides a range of solutions to your technology needs