Close Menu
    Facebook X (Twitter) Instagram
    • Download Cisco Packet Tracer
    Facebook X (Twitter) Instagram Pinterest Vimeo
    IT Beginner
    • Home
    • Server
    • WordPress
    IT Beginner
    Home»Tips – Tricks»How to install mod_rewrite on Ubuntu
    Tips – Tricks

    How to install mod_rewrite on Ubuntu

    18/07/2017No Comments1 Min Read

    mod_rewrite will not be isntalled by default when you install apache web server and php on Ubuntu. To use mod_rewrite on ubuntu you can use the the following command in the terminal

    # a2enmod rewrite

    Restart apache2 server

    # /etc/init.d/apache2 restart

    you can use the following sample .htaccess file

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    The sample .htaccess file will redirect all traffic to an index.php file in the DocumentRoot unless the file exists. Let’s say you have the following directory structure and httpdocs is the DocumentRoot

    httpdocs/ .htaccess index.php
    images/ image1.jpg image2.jpg
    js/ jquery.js
    css/ style.css

    Any file that are in httpdocs will be given to the requester by the .htaccess file. Anything else that does not exist will be redirect to httpdocs/index.php

    apache mod_rewrite Ubuntu web server
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleHow to update and upgrade with fastest mirror from the command line
    Next Article How to redirect 404 to homepage in wordpress

    Related Posts

    Tips – Tricks

    How to fix nginx an upstream response is buffered to a temporary file error

    05/08/2017
    Tips – Tricks

    Optimize WordPress with Nginx

    04/08/2017
    Security

    How to secure Nginx web server

    02/08/2017
    Subscribe
    Notify of
    guest

    guest

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    0 Comments
    Oldest
    Newest Most Voted
    Inline Feedbacks
    View all comments
    Tags
    apache centos Centos 6 cuda Desktop Environment dual boot environment featured gnome GUI hostname hosts intel kernel kill lamp server lemp server life MariaDB netflix nginx nvidia password php-fpm phpmyadmin pids processes s.m.a.r.t Security session solid state drive ssd ssh ssh server tag 1 tag 2 Ubuntu upgrade varnish VirtualBox VNC Server web server window manager wordpress xfce
    Facebook X (Twitter) Instagram Pinterest

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

    wpDiscuz