How to enable apache mod_rewrite on ubuntu

I have been moving my development to Linux lately and had the first real struggle getting the rewrite stuff working on Apache. Problem wasn’t that I didn’t know how to do it, (BTW usually i would prefer to have a self compiled version of Apache as I would know what’s in it) but that the configuration files were all so different from what I am used on Leopard and BSD etc.. Anyway so here’s what I did.

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

To disable an Apache 2 module, you can run:

# sudo a2dismod rewrite
# sudo /etc/init.d/apache2 restart

That does the reverse.

With mod_rewrite enabled, you can use the .htaccess file.By the way in your directory permissions, you must set AllowOverride to “all” like this:

[config]

Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all

[/config]

HTH

About rp

Architect for large, highly scalable LAMP applications and Technical Manager with special focus on metrics based continuous improvement of teams and products. Rajat has close to a decade of experience of a very wide range of skills related to infrastructure, middleware, app servers all the way to front-end technologies and software development methodologies including agile, iterative waterfall, waterfall as well as ah-hoc startup using the right approach in the right context to reduce time to market.