mod_rewrite and sh404sef Explained

master-mod rewrite-sh404Learning to manage your URLs in is an important step in keeping your website clean and user-friendly. Not to mention search engines can use words and structure of URL's to help users find content.

This guide is focused on getting you started with using sh404SEF with mod_rewrite.

We will talk about:

  1. How mod_rewrite works
  2. Good URL structures
  3. Alias & Category Settings in sh404SEF
  4. Redirecting with sh404SEF

What Is mod_rewrite?


mod_rewrite is short for module rewrite. It is a module built to work with the Apache server application that can control URL's from the server level. Most hosting companies use it or have it available. It helps to protect your website and gives you an added layer of security. It is also used for aesthetic purposes like creating easier to read URL's from hard to read ones.

For Example:
This URL

Turns into this

How Do You Use mod_rewrite?

To use the module rewrite you can enter code into the .htaccess file. This is a files that allows users to write rules. You can write rules that turn URL's like the one above into something readable. It has even been used to block users from seeing images on their site that they are not supposed to see.

We choose not to rewrite these rules by hand, instead we use a great Joomla plugin called sh404SEF. It can handle all of these rules and writes them for you.

If you want to learn more about writing rules for mod_rewrite visit this helpful documentation at the Apache website

Good & Bad URL's


Good URL's (Or readable URLs) are known as SEF urls. SEF = Search Engine Friendly

Bad URLs are .... well... bad. As you can see from the example above this URL: is clearly not very useful. Both people and search engines like when it's easy to read the URL. This means, you should spend time thinking about how you want to organize your website so that your URL's make sense.

At we try not to go beyond 3 levels. is one of our longest urls. We have several big categories like 'Joomla Basics'. We have ones like 'reviews', 'performanc', etc... Then after the category we have our article titles. We feel like this is a good structure. There probably isn't a reason to go 4 levels deep unless you have a ton of articles and categories.

Alias & Category settings in sh404SEF


Some Basic Settings:

  1. In this section you can set to use the alias created by Joomla in the URL's. Alias' are created when you start a new article, category, or menu item. When you name that item a lowercase, dash-separated alias is created. Set these otptions to 'Yes' to use those aliases.
  2. This a powerful tool. Setting when to show the category can change the whole structure of your site. Decide before hand how you want this to work.

Heres how our categories with the different options
pretend this is our URL:

  • Top one only:
  • Last one only:
  • Top two:
  • Last 2:

Redirecting With sh404SEF


The easiest way to redirect one URL to another in sh404SEF is by using 'Url manager'.

Say you want to redirect a URL like the one below:




  1. Search for the latter and click on it. Go to the 'Aliases' tab and add the url you desire to redirect into the field.
  2. Click "Save"

About The Author

David writes for several websites. Specializing in Joomla, he develops websites like this one in order to provide help to those who need it. He enjoys taking concepts not everyone understands and breaking them down so that it is easy for everyone. On the weekends he can be found having beers with friends, watching soccer and enjoying the outdoors.