Mar 20

In order to enable the mod_rewrite module in the Ubuntu server issue the following command:

# a2enmod rewrite

The above Apache2 Enable Module command will add the correct line in the /etc/apache2/apache2.conf file. The precise command will be added on /etc/apache2/mods-enabled/rewrite.load

LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

then restart your apache2

#/etc/init.d/apache2 restart

then checked your apache modules on your phpinfo, create phpinfo.php on your web root directory

<? phpinfo(); ?>

then browse it

New Picture

Simple test:

Nice looking URLs (no querying) with pagination:
Suppose your url is: domain.com/article.php?name=title&page=5
You want to change: domain.com/articles/title/5/
Then write in .htaccess file:
RewriteRule ^articles/(A-Za-z0-9-]+)/([0-9]+)/?$ article.php?name=$1&page=$2 [L]

The rule is defined in regular expression. Here [L] means Last Rule. It’s called RewriteRule Flags.

Leave a Reply