Pretty URLs are URLs that have meaning for human readers, rather than just being seemingly random jibberish only a web server could appreciate. The following is an example of a “pretty” URL:


http://my.blog.com/archive/2007/10/pretty-urls

Note that every part of the URL is relevant for a human reader. For comparison, here’s an example of an “ugly” URL:


http://www.mysite.com/nuke/modules.php?name=Forums&file=posting&mode=quote&p=14488&sid=0293840293840577

To enable the mod_rewrite module in Apache2 on Ubuntu:

(1) Add the rewrite.load to /etc/apache2/mods-enabled/

sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/

(2) Edit the apache configuration for your virtual hosting (/var/www/):

sudo nano /etc/apache2/sites-enabled/000-default

(3) Change the AllowOverride value to “All” for the document root directory:

<directory /var/www/>
  Options Indexes FollowSymLinks MultiViews
  AllowOverride All
  Order allow,deny
  allow from all
  # This directive allows us to have apache2's default start page
  # in /apache2-default/, but still have / go to the right place
  # Commented out for Ubuntu
  #RedirectMatch ^/$ /apache2-default/
</directory>

(4) Restart the server:

sudo /etc/init.d/apache2 restart


Readers' Comments

  1. |

    thanks vrey much!!!

    you just saved me a lot of time!

    i’m glad you published that.

Leave a Comment

Basic HTML tags and Markdown syntax are allowed.