Novell is now a part of Micro Focus

How to Redirect all Web Traffic on Server to Port 443

Novell Cool Solutions: Tip
By Cade Carvell

Digg This - Slashdot This

Posted: 31 Aug 2005


Need to redirect all web traffic on a specific server to 443 - for security purposes.


"This is a cool way to make sure all your traffic is using the secure port."
--Aaron Gresko, Product Specialist

Create a script and place it in /etc/apache2/conf.d that takes any request that comes in that is not on port 443 and transfer them to port 443.


#This module simply tells apache2 that all connections to
#port 80 need to go to port 443 - SSL - No exceptions
<IfModule !mod_rewrite.c>
  LoadModule rewrite_module modules/
<IfModule mod_rewrite.c>
  RewriteEngine on
# The line below sets the rewrite condition.  That is, 
if the server port does not equal 443, then this condition is true
  ReWriteCond %{SERVER_PORT} !^443$
#  The line below is the rule, it states that if above 
condition is true, and the request can be any url, then redirect 
to https:// plus the original url that was requested.
  RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]

Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions.

© Copyright Micro Focus or one of its affiliates