How to enable mod_rewrite in Ubuntu 14.04 LTS
A little note first: This is the most basic way to enable mod_rewrite. However, it’s not the best way. The more correct way would be to setup a vhost and change its config, but unless you are a professional and know exactly what you do this thing will do the job perfectly.
Please note that Ubuntu 14.04 LTS comes with Apache 2.4, while Ubuntu 12.04 LTS came with Apache 2.2. This new version introduced different default config filenames and in general some differences.
Activate the mod_rewrite module with
sudo a2enmod rewrite
and restart the apache
sudo service apache2 restart
To use mod_rewrite from within .htaccess files (which is a very common use case), edit the default VirtualHost with
sudo nano /etc/apache2/sites-available/000-default.conf
Search for “DocumentRoot /var/www/html” and add the following lines directly below:
<Directory "/var/www/html"> AllowOverride All </Directory>
Save and exit the nano editor via CTRL-X, “y” and ENTER.
Restart the server again:
sudo service apache2 restart
Voila! To check if mod_rewrite is installed correctly, check your phpinfo() output. It should have this in it:
Tested and working in Ubuntu 16.04 :)
Thanks you friend, you help me. i love you
Thanks
Bullshit it works nothing! I do the same, i have a white site. The Help is for the ass
your shitty website doesn’t even use this feature… but thanks for the spam.
did not work w ubuntu 14.04… and does not cover making sure it works in user_dir examples. /home/$USER/public_html
Thanks a lot man, classic newbie mistake, been bothering for hours. Good work!
Thankkk Yoooooo. Awesome & Easy
You just save my life dude… God Bless You :)
Получилось с первого раза. Огромное спасибо автору за статью!
Worked Perfect!!
Only config file name is not ‘000-default.conf’ in my system(12.04 LTS). Its ‘default’ only.
Thanks a lot man!!!
He, the article is clearly for 14.04, not 12.04 (two totally different things!) :)
Thank you for this
Thanks :)
In your recent video about performance myths it was advised not to use AllowOverride All but to put the rewrite rules in the config file and not to use htaccess.
wonderworld !
thanks man, you really helped me
thanks you so much.. its very helpfull
Works like a charm!
after i put AllowOverride All
i cannot access anymore the website , receiving Forbidden
permalinks still not working
It works like a charm
Thank You
Thanks, this worked for me.
Thanks, brother! Simple helpful.
It worked! Thanks!
Thanks, was looking for hours for this solution.
Great thanks alot
Thank you
Very useful tutorial. Explained it very well.
Thank you for this
Guy, you saved my life. You are the guy! Thanks a lot!
Very useful tutorial. Explained from basics..
Than you so much..
please i tried mine but it did not work… :) Oops but is working now. Thanks!!!
Thank you so much
I’m not a professional, so your post is very useful. Thanks you so much
Works perfectly! Cheers.
Works wellla!
Thanks! you save me
Cakephp:
Found it! Somewhere along the line I thought it was a good idea to uncomment this line in Config/core.php:
Configure::write(‘App.baseUrl’, env(‘SCRIPT_NAME’));
But this is for when url rewriting is NOT enabled, so putting the comment back in did the trick!
Thank you for these straight-forward instructions! They work perfect for me even in Zorin OS 9 (based on Ubuntu 14.04LTS) ;-)
it does not work o
I had the same reaction, but look closer to your code. In my case, the mod rewrite it wasn’t work because my Rewrite Rule in my .htaccess that redirects to other place. This article works just fine, but we need to configure correctly our website