Apache mod_rewrite configuration example 


September 12, 2014 12:10:00    Last update: September 12, 2014 12:10:00
  1. In Apache conf, load mod_rewrite:
    LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

    or, simply create symlink /etc/apache2/mods-enabled/rewrite.load on Ubuntu.
  2. In directory conf, set AllowOverride:
    <Directory /var/www/html>
    	    Options Indexes FollowSymLinks
    	    Require all granted
    	    AllowOverride All

  3. Create .htaccess file:
    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /
    RewriteRule ^Google$ https://www.google.com [R=302,NC,L]

    where NC means case-insensitive match, L means this is the last rule, no more rules will be processed (if there are more rules following the current one).

See documentation.
Share |
| Comment  | Tags