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 (8 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
  •  Netflix JavaScript Talks about ECMAScript 7: The Evolution of JavaScript Netflix JavaScript Talks about ECMAScript 7: The Evolution of JavaScript
  • Symfony devs: Creator of Symfony framework is hiring (Cologne, Germany)!Symfony devs: Creator of Symfony framework is hiring (Cologne, Germany)!
  • A super-simple introduction into PHP namespaces (7min video)A super-simple introduction into PHP namespaces (7min video)
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

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

Microsoft enters post-password era with Hello (promo video)

Just a short promotion clip, but definitly interesting: Microsoft announces Hello, the authentication system inside Windows 10, using fingerprints, iris

phpstorm-github-code-color-syntax-theme

Get Github’s syntax highlighting colors in PHPStorm

I really really like the colors on GitHub’s code previews but couldn’t find any themes that copy that in a

set up a local virtual machine for development with vagrant and puphpet / puppet (and ubuntu, linux, php, apache, mysql)

A list of downloadable Vagrant boxes (CentOS 5.9 / 6.4, Ubuntu 12 / 13, Debian 6 / 7 / 7.1 / 7.2)

Offical boxes (directly from Vagrant) Ubuntu 12.04 LTS 32-bit http://files.vagrantup.com/precise32.box Ubuntu 12.04 LTS 64-bit http://files.vagrantup.com/precise64.box   Boxes from puppetlabs.com Seems

Useful basic linux stuff: Show kernel version, distribution name and distribution version on Ubuntu systems

Always nice to know: Show kernel version: uname -r Show kernel version and CPU: uname -a Show distribution version: lsb_release

How to show memory usage (Ubuntu)

Always very useful: A simple command to show memory usage (Ubuntu / linux distros). cat /proc/meminfo   This article was

php

How to install PHP curl extension (in 5 seconds)

It’s a common wordpress problem: PHP’s curl extension is not installed! No need to mess around in config files etc,

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

phpstorm-8

PHPStorm 8 (early access version) released – for free

JetBrains have just released an Early Access version of the upcoming PHPStorm 8. In case you never worked with PHPStorm

compress-png

Compress png, jpeg, gif and svg up to 90% with Compressor.io

What a fantastic tool: Compressor.io is a totally free service that let you compress png, jpeg, gif or svg files

1/4

Categories

Search

js javascript
[video] Netflix JavaScript Talks about ECMAScript 7: The Evolution of JavaScript
How to show the available version of a package (before doing apt-get install)
angularjs
Two excellent introductions into AngularJS by Todd Motto
php mvc
Preview-release of (my) “php-mvc” project (a simple php mvc barebone)
How to install/setup latest version of PHPMyAdmin on Ubuntu 12.04 LTS (Precise Pangolin)
Frontend Ops Conf 2014 – Sarah Goff-Dupont: Git, Continuous Integration and Making It Pretty (31min video)
php
Is there a JSFiddle for PHP ? Yes !
Ghost
[FREE SERVER PROMO] Install GHOST for free on a free SSD server with this coupon
sass
[german video] Modernizing and minimalizing frontend markup code at AutoScout24
github-logo-octocat
GitHub rolls out .PSD diff and viewing
Interesting stats on SONY’s hacked passwords
php
Test out PHP 5.6alpha1 on Windows 7 / 8 with two clicks
js javascript
Push database changes to all clients in real-time (!) with AngularJS and Firebase
php
[Link] How to create, read, update and delete (CRUD) with PDO, MySQLi and MySQL the right way (prepared statements)
MINI2, an extremely simple barebone PHP application on top of Slim

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 All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
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