Press "Enter" to skip to content

Posts published in “Day: August 17, 2014”

Apache SSL Redirect

Need to redirect all traffic to an Apache server from HTTP (Port 80) to HTTPS (port 443)?

Just add a redirect statement in your httpd.conf for that server.

[code]
<VirtualHost *:80>
DocumentRoot "/path/to/greyfuzz.com"
ServerName https://www.greyfuzz.com
ServerAlias greyfuzz.com
ErrorLog logs/greyfuzz-error.log
CustomLog logs/greyfuzz-access_log combined
Redirect / https://www.greyfuzz.com/
<Directory "/path/to/greyfuzz.com">
Your directory options
</Directory>
</VirtualHost>
[/code]

Line #7 above does the magic for you.

Be sure to include the trailing ‘/’ on the end of the domain being redirected,
without it you may get some untoward URLs that look like
https://www.greyfuzz.comindex.php instead of https://www.greyfuzz.com/index.php.

Note: Be certain your conf.d/ssl.conf (or equivalent) is already set up and HTTPS is working properly first.