Operating System - HP-UX
1847474 Members
3055 Online
110265 Solutions
New Discussion

Re: Apache2 Redirect question

 
Leon A. Howorth
Advisor

Apache2 Redirect question

I set up a web site using Apache2, listening on port 80 and port 443, same IP address, with SSL enabled by means of a secure server certificate for the port 443 virtual host. I would like users to be able to initially access the web site via port 80 (i.e., not have to use "https" instead of the default "http") -
BUT after this initial connection I would like the entire remainder of the client browser - web server session to be conducted via port 443 and "https", preferably without the unsecure (port 80) web site having to be involved at all, and without any actions needed on the part of the user. So if the client initially connects to "http://test.mywebsite.com" I want to force the client's browser to reconnect to "https://test.mywebsite.com" and conduct all further business there.
2 REPLIES 2
Jairo Campana
Trusted Contributor

Re: Apache2 Redirect question

hello:
*****************************
see you: http://httpd.apache.org/docs/mod/mod_alias.html
*****************************
Other
Using mod_rewrite to re-direct http requests to https
Compile apache with the rewrite module as described above.
Add the following to the httpd.conf:
UseCanonicalName Off

#############################
# Mod rewrite stuff
#############################

# rewrite environment
RewriteEngine on
RewriteLog /www/var/log/https_rewrite_log
RewriteLogLevel 1

# redirect http to https
# If you don't try to access https, then redirect to https
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [L,R]


If you add any virtual hosts, you also need to add:


RewriteEngine on
RewriteOptions inherit

to each VirtualHost entry.

for more help:
http://www.kordy.dircon.co.uk/misc/mod_ssl.html

other option is using .htacces
legionx
Brian Bergstrand
Honored Contributor

Re: Apache2 Redirect question

There are two ways to do this.

1) In your apache config file for the port 80 vhost

Redirect / https://test.mywebsite.com

2) In your index.html file for the port 80 vhost

<meta http-equiv="refresh" content="0; URL=https://test.mywebsite.com" />

HTH.