Logo
  • PHP
    • HipHop / HHVM
    • Modern PHP
    • PHPStorm
    • LAMP
    • Laravel
    • Composer
    • PDO
  • JavaScript
    • node.js
    • AngularJS
  • CSS
    • SASS
    • “CSS4” (CSS level 4)
  • HTML
  • Git
  • LAMP
  • Vagrant
  • UI / UX
  • Architecture of …
  • Off-Topic
With ♥ from Berlin
April 21, 2014
Chris
LAMP, Linux, Local Development, PHP, Server, Ubuntu
50

How to enable mod_rewrite in Ubuntu 14.04 LTS

PreviousNext

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:

mod-rewrite-apache-2-4

This article was written quite a while ago (9 years), please keep this in mind when using the information written here. Links, code and commands might be outdated or broken.

Random articles

  • [RePost] Goodbye LAMP: Going Nginx, NoSQL, HHVM (41min conference talk with Arne Blankerts)[RePost] Goodbye LAMP: Going Nginx, NoSQL, HHVM (41min conference talk with Arne Blankerts)
  • Hochlastseiten mit PHP, MySQL und Apache am Beispiel stern.de (deutscher Artikel)Hochlastseiten mit PHP, MySQL und Apache am Beispiel stern.de (deutscher Artikel)
  • How to install/setup a basic LAMP stack (Linux, Apache, MySQL, PHP) on Ubuntu 14.04 LTSHow to install/setup a basic LAMP stack (Linux, Apache, MySQL, PHP) on Ubuntu 14.04 LTS
  • Install Laravel 4 on Ubuntu 12.04 LTS (a how-to tutorial)Install Laravel 4 on Ubuntu 12.04 LTS (a how-to tutorial)
  • How to install/setup a basic LAMP stack (Linux, Apache, MySQL, PHP) on Ubuntu 12.04 or Debian 7.0/7.1How to install/setup a basic LAMP stack (Linux, Apache, MySQL, PHP) on Ubuntu 12.04 or Debian 7.0/7.1
  • How to enable mod_rewrite in Ubuntu 12.04 LTSHow to enable mod_rewrite in Ubuntu 12.04 LTS
  • Create a fast, perfect and bootable 1:1 Windows backup (full clone of HDD) for SSD migrationCreate a fast, perfect and bootable 1:1 Windows backup (full clone of HDD) for SSD migration
  • Migrating Wikipedia to HHVM (@Scale Conference 2014)Migrating Wikipedia to HHVM (@Scale Conference 2014)
  • Slides & talks from PHP UK Conference 2014Slides & talks from PHP UK Conference 2014
apachemodmod_rewriterewrite
Share this

50 Comments

  • JP
    March 14, 2018 10:44 pm

    Tested and working in Ubuntu 16.04 :)

    Reply
  • Mauricio hoyos diaz
    February 21, 2017 8:55 pm

    Thanks you friend, you help me. i love you

    Reply
  • Chema Gallego
    June 10, 2016 3:57 pm

    Thanks

    Reply
  • cec0r
    December 29, 2015 7:55 pm

    Bullshit it works nothing! I do the same, i have a white site. The Help is for the ass

    Reply
  • tellitlik ehtis
    November 5, 2015 8:27 pm

    your shitty website doesn’t even use this feature… but thanks for the spam.

    Reply
  • fuhk disqus
    November 5, 2015 7:26 pm

    did not work w ubuntu 14.04… and does not cover making sure it works in user_dir examples. /home/$USER/public_html

    Reply
  • Alexandros Mylonas
    July 10, 2015 2:13 am

    Thanks a lot man, classic newbie mistake, been bothering for hours. Good work!

    Reply
  • Adam Davies
    June 25, 2015 11:48 pm

    Thankkk Yoooooo. Awesome & Easy

    Reply
  • Dimas Seputro
    June 20, 2015 6:07 pm

    You just save my life dude… God Bless You :)

    Reply
  • Дмитрий Горбачев
    June 10, 2015 4:19 pm

    Получилось с первого раза. Огромное спасибо автору за статью!

    Reply
  • Devang Jalgaonkar
    June 10, 2015 12:09 pm

    Worked Perfect!!
    Only config file name is not ‘000-default.conf’ in my system(12.04 LTS). Its ‘default’ only.

    Thanks a lot man!!!

    Reply
    • Chris
      June 13, 2015 11:59 pm

      He, the article is clearly for 14.04, not 12.04 (two totally different things!) :)

      Reply
  • Fetch404
    May 30, 2015 6:00 pm

    Thank you for this

    Reply
  • Marcos Martins
    May 2, 2015 7:46 am

    Thanks :)

    Reply
  • meulendreez
    April 29, 2015 10:40 am

    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.

    Reply
  • Dan
    April 26, 2015 9:54 pm

    wonderworld !

    Reply
  • Frederico Bruno
    April 25, 2015 6:36 pm

    thanks man, you really helped me

    Reply
  • Vaibhav Jamadade
    April 20, 2015 8:55 am

    thanks you so much.. its very helpfull

    Reply
  • Marcos Aguilera Ely
    April 17, 2015 8:20 pm

    Works like a charm!

    Reply
  • WebDesign Roma
    April 15, 2015 10:17 am

    after i put AllowOverride All
    i cannot access anymore the website , receiving Forbidden
    permalinks still not working

    Reply
  • Tanmay
    April 11, 2015 10:25 pm

    It works like a charm
    Thank You

    Reply
  • Victor
    March 10, 2015 3:08 pm

    Thanks, this worked for me.

    Reply
  • Taras Bulba
    February 26, 2015 5:09 pm

    Thanks, brother! Simple helpful.

    Reply
  • Ilham Akbar
    January 18, 2015 4:18 pm

    It worked! Thanks!

    Reply
  • Simon
    January 17, 2015 4:49 am

    Thanks, was looking for hours for this solution.

    Reply
  • Peter Munyasi
    January 6, 2015 10:00 am

    Great thanks alot

    Reply
  • mehdi lamaafar
    December 28, 2014 6:12 am

    Thank you

    Reply
  • Prakash Shrestha
    December 26, 2014 12:11 pm

    Very useful tutorial. Explained it very well.

    Reply
  • hallowcard13
    December 13, 2014 7:25 pm

    Thank you for this

    Reply
  • Alexandre Landskron
    December 10, 2014 11:52 pm

    Guy, you saved my life. You are the guy! Thanks a lot!

    Reply
  • Vaibhavraj S. Roham
    November 24, 2014 4:17 pm

    Very useful tutorial. Explained from basics..
    Than you so much..

    Reply
  • Udeme Samuel
    November 12, 2014 5:34 am

    please i tried mine but it did not work… :) Oops but is working now. Thanks!!!

    Reply
  • acrord32
    November 1, 2014 8:32 pm

    Thank you so much

    Reply
  • Dũng Ninh Bình
    September 15, 2014 3:25 pm

    I’m not a professional, so your post is very useful. Thanks you so much

    Reply
  • Kamran Ahmed
    September 2, 2014 6:01 pm

    Works perfectly! Cheers.

    Reply
  • xxxx
    August 29, 2014 9:05 am

    Works wellla!

    Reply
  • rama
    August 27, 2014 10:57 am

    Thanks! you save me

    Reply
  • Mani Maran
    July 28, 2014 8:31 am

    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!

    Reply
  • Testaff
    July 22, 2014 5:07 pm

    Thank you for these straight-forward instructions! They work perfect for me even in Zorin OS 9 (based on Ubuntu 14.04LTS) ;-)

    Reply
  • porlo
    June 23, 2014 5:08 am

    it does not work o

    Reply
    • rhamses
      July 6, 2014 9:37 pm

      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

      Reply

Leave A Comment Cancel reply

A collection of beautiful ajax loaders / spinners in pure .svg / CSS

No images used, pure svg/css and scaleable. Bookmark now! Brent Jackson‘s ajax spinner / loader library on the project’s demo

Quick fix for 404 error in WordPress category / tag page

Just a quick fix for a common problem: Sometimes, especially after switching themes, wordpress will generate 404 errors on the

GitHub finally introduces repo traffic stats

It has been a veeeery long time, but finally GitHub has introduced private traffic stats for all projects. To open

vagrant

A preinstalled Vagrant box with PHP HipHop / HHVM and Ubuntu 12.04 (Precise Pangolin)

This is the same post like this one, but this time with Ubuntu 12.04 Precise Pangolin. If you need to

vagrant

A super-simple Vagrant LAMP stack bootstrap (installable with one command)

As I have to setup servers inside Vagrant quite often, sometimes 10 times per day, I started to use provisioning:

digitalocean coupon

DigitalOcean VPS coupon codes for december 2013 and early 2014

Some (working!) coupon codes for DigitalOcean, the low-cost VPS server/hosting provider of the year. They are for NEW customers, but

bitdeli git github stats

php-login goes #2 PHP script worldwide in BitDeli stats

Holy! I just checked the stats of my little php-login hobby project on BitDeli (the tracking service for GitHub) and

PHPMyAdmin not found after installation ? Here’s a fix (Ubuntu 12.04) !

You just installed PHPMyAdmin but http://www.yourdomain.com/phpmyadmin just says “phpmyadmin not found” ? Try to create a link in /var/www like

Creators of Laravel launch one-click-installations of Laravel (including nginx, PHP 5.5 etc.)

Again, a game changer: Taylor Otwell, creator of Laravel (which is currently the most popular PHP framework), has released FORGE

php

[Link] How to create, read, update and delete (CRUD) with PDO, MySQLi and MySQL the right way (prepared statements)

Mike Dalisay has written an excellent tutorial on the CORRECT USAGE of basic CRUD functions (create, read, update, delete) with

1/4

Categories

Search

set up a local virtual machine for development with vagrant and puphpet / puppet (and ubuntu, linux, php, apache, mysql)
A super-simple pre-configured Vagrant box with HipHop, Hack and Hack code examples
phpstorm-github-code-color-syntax-theme
Get Github’s code colors in PHPStorm (2014 style)
DigitalOcean coupon voucher 50
Only today: $50 coupon for DigitalOcean SSD VPS / hosting
JavaScript ECMAScript6 – A short video introduction (5min)
java vs php
Switching from Java to PHP. Seriously. A very interesting and pre-judice-free talk with Ph.D. Aris Zakinthinos
Frontend Ops Conf 2014 – Rebooting Flickr On A Node.js Stack, One Page At A Time (from PHP) by Bertrand Fan
php
How to install/setup latest version of PHP 5.5 on Debian Wheezy 7.0/7.1/7.2 (and how to fix the GPG key error)
How major web companies (and banks) handle passwords quite wrong
Install MINI in 30 seconds inside Ubuntu 14.04 LTS
js javascript
JavaScript Testing Tactics (21min video by Justin Searls)
phpstorm-8
Killer-feature in PHPStorm: Search everywhere
mod-rewrite-ubuntu-14-04-lts
How to enable mod_rewrite in Ubuntu 12.04 LTS
ubuntu-14-04-lts lamp
How to install/setup a basic LAMP stack (Linux, Apache, MySQL, PHP) on Ubuntu 14.04 LTS
phpstorm 7.0 php
How to install GitHub’s, NetBeans’s and Sublime2’s syntax highlighting code colours theme in PHPStorm 6/7
symfony-framework-logo
SensioLabs, creator of Symfony and Silex PHP frameworks, gets $7 million capital

Tags

apache bash centos composer conference coupon CSS debian fonts framework git GitHub hack HHVM HipHop HTML HTML5 IDE JavaScript JS LAMP laravel linux mod_rewrite MVC MySQL Nginx optimization PHP PHP 5.5 PHP 5.6 phpmyadmin PHPStorm security server SSD Ubuntu UI UX vagrant video virtual machine voucher VPS wordpress
Side-Project: Wordle-Solver:
www.wordle-helper.info

Pages

  • Privacy Policy
 
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT