How to enable clean URL’s in Apache.

A clean url could be something like instead of


Some installations of apache have clean URL functionality out of the box. There are 2 steps that need to be configured correctly for it to work.

  1. Enable rewrite module
  2. Allow .htaccess file overrides

Both steps require SSH root access to your server. So if you are on shared host this probably won't work for you. Open your terminal:


1. Enable rewrite module

To enable the rewrite module, you can type the following command


sudo a2enmod rewrite

Now type

sudo service apache2 restart

to enable the changes. You can check if it’s working by typing

sudo apache2ctl –M

A list will appear. Look for “rewrite_module”.


2. Allow .htaccess file overrides

Now you need to see if your config file is properly set up (it is often here there is a problem). Find your main config file (or the config file for your domain if you have the settings configured there (you will have to look at both files if you don’t know).

The main config file is usually found by typing:

sudo nano /etc/apache2/apache2.conf

If your files for your site are located in “var/www” look for this string: “<Directory /var/www>” and replace this line

AllowOverride None

with this

AllowOverride All

now enable the changes by typing

sudo service apache2 restart

If you still can’t see clean url’s it’s probably cause your .htaccess file is not correctly set up (placed at the root of your site). Since this file now has full control of your url-settings for your domain if you followed step 2.'

Karsten Madsen

I mostly write about ideas and concepts. My passion is bulding stuff for the future and how we can improve ethics in this world. On this site my writings will relate to my struggles in web development and technical SEO :)