Here's an explanation of how to use rewrite module
install httpd via apt-get.
# apache2 -v
Server version: Apache/2.2.20 (Ubuntu)
Server built: Feb 14 2012 16:35:38
|
find in which directory mod_rewrite.so exists.
# locate mod_rewrite.so
/usr/lib/apache2/modules/mod_rewrite.so
|
make *.load file under /etc/apache2/mods-enabled/ directory.
# cat /etc/apache2/mods-enabled/rewrite_mod.load
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
# cat /etc/apache2/mods-enabled/mod_ssl.load
LoadModule ssl_module /usr/lib/apache2/modules/mod_ssl.so
|
edit /etc/apache2/sites-available/default file.
“AllowOverride None” to “AllowOverride All”
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
# AllowOverride None
AllowOverride All
Order allow,deny
allow from all
</Directory>
|
restart apache
# /etc/init.d/apache2 restart
|
if a client accesses to http://web server’s IP/test/zzz.html , Apache will redirect that client to https from http.
# less /etc/apache2/sites-available/default
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
ServerName mint-1
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
# AllowOverride None
AllowOverride All
Order allow,deny
allow from all
RewriteEngine ON
RewriteRule ^test/zzz.html https://mint-1/test/zzz.html [L,R]
</Directory>
|
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.