Apache mod_rewrite configuration example
September 12, 2014 12:10:00 Last update: September 12, 2014 12:10:00
- 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. - In directory conf, set
AllowOverride
:<Directory /var/www/html> Options Indexes FollowSymLinks Require all granted AllowOverride All </Directory>
- Create
.htaccess
file:Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteRule ^Google$ https://www.google.com [R=302,NC,L]
whereNC
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.