Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Web Servers»Apache»How to Enable Apache mod_rewrite Module in Ubuntu & Debian

    How to Enable Apache mod_rewrite Module in Ubuntu & Debian

    RahulBy RahulMay 16, 20152 Mins ReadUpdated:December 30, 2021

    The Apache mod_rewrite module is a rewriting engine based on defined rules. The Apache rewrite engine maps a URL to a directory path as well as to other URLs. In this tutorial, you will learn, how to enable the Apache mod_rewrite module and configure VirtualHost to use .htaccess files available under the document root.

    Sometimes you faced issues the Apache server is not reading your .htaccess or Apache is not rewriting URLs while we are using correct rewrite rules in configuration files. This happens due to the Apache rewrite module is not being enabled. When we installed a fresh Apache server mod_rewrite is not enabled by default on your server, So to use rewrite configurations you need to manually enable the mode_rewrite module on your system.

    Enable Apache2 mod_rewrite Module

    We use a2enmod command to enable any modules in Apache2 web server. So use following command to enable mod_rewrite module in your Apache setup.

    sudo a2enmod rewrite
    

    Enable .htaccess for VirtualHost

    After enabling the Apache rewrite module, now you need to add “AllowOverride All” in your VirtualHost configuration file.

    Apache
    1
    2
    3
    4
    5
    6
    7
    8
    <VirtualHost *:80>
        ServerName  www.example.com
        DocumentRoot /var/www/html
     
        <Directory /var/www/html>
            AllowOverride All
        </Directory>
    </VirtualHost>

    This setting can also be enabled globally by editing the Apache main configuration file.

    Apache
    1
    2
    3
    4
    <Directory /var/www/html>
        Options Indexes FollowSymLinks
        AllowOverride All
    </Directory>

    Restart Apache2

    After enabling the mod_rewrite module in Apache you also need to reload the Apache2 server to reload all configurations to the running environment.

    sudo systemctl restart apache2
    
    Apache Linux Mint mint Modules rewrite Ubuntu
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to enable or disable Apache2 Modules
    Next Article Fedora 22 Released and Available to Download

    Related Posts

    Change Screen Resolution of An Ubuntu VM in Hyper-V

    Updated:May 2, 20222 Mins Read

    How to Install Apache ActiveMQ on Ubuntu 22.04

    3 Mins Read

    Download Ubuntu 22.04 – DVD ISO Images

    Updated:May 7, 20222 Mins Read

    How To Install LAMP Stack on Ubuntu 22.04 LTS

    Updated:April 20, 20225 Mins Read

    How To Disable HTTP Methods in Apache

    Updated:December 31, 20212 Mins Read

    Ubuntu 22.04 – Release Schedule & Features

    Updated:February 25, 20222 Mins Read

    2 Comments

    1. MrSatoV on August 9, 2020 2:17 pm

      “…in your VirtualHost configuration file.”
      “…by editing the Apache main configuration file.”
      Would you mind sharing the location of these?

      Reply
      • Kris on October 31, 2020 11:12 pm

        /etc/apache2/apache2.conf is the main configuration file
        the VirtualHost files are in /etc/apache2/sites-enabled

        Reply

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    • How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04
    • (Resolved) Please install all available updates for your release before upgrading
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.