Easy Peasy Ubuntu powered Drupal Clean-URLs w/ Apache2

This brief blog entry will note the couple of forgettable steps to enabling Drupal's Clean-URLs on a freshly installed Ubuntu GNU/Linux web-server. First, we check if the rewrite_module is already loaded or not.

apache2ctl -M

Example output

Loaded Modules:
core_module (static)
log_config_module (static)
logio_module (static)
mpm_prefork_module (static)
http_module (static)
so_module (static)
alias_module (shared)
auth_basic_module (shared)
authn_file_module (shared)
authz_default_module (shared)
authz_groupfile_module (shared)
authz_host_module (shared)
authz_user_module (shared)
autoindex_module (shared)
cgi_module (shared)
dir_module (shared)
env_module (shared)
mime_module (shared)
negotiation_module (shared)
php5_module (shared)
<strong>rewrite_module (shared)</strong>
setenvif_module (shared)
status_module (shared)
Syntax OK

No rewrite_module (shared) listed? No problems...

sudo a2enmod rewrite
sudo /etc/init.d/apache2 restart

Next enable the RewriteRule in the default directory (/var/www)

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

Find

#RedirectMatch ^/$ /apache2-default/

Replace with
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Reload and Fin
sudo /etc/init.d/apache2 restart

Tags