Author |
|
kcatta
Joined: 13 Jan 2011 Posts: 3
|
Posted: Thu 13 Jan '11 23:32 Post subject: Getting Apache to redirect http to https... |
|
|
Hi Everyone,
I just wanted to let everyone know this is all very very new to me! And I'm sure I've gone about this the wrong way so far. I have Apache 2.2.17 /w OpenSSL installed on Windows Server 2008 (x86). So far I've managed to get the site up and running normally (through http), I've managed to create and use my certs so both http and https work but I want to setup the site to allow only https.
Everything I've done in httpd.conf, https-ssl.conf and https-vhosts.conf has been from reading on different forums and trying to peice things together, but I need to bow my head and ask for some real help as I've spent too long on this.
The main option I've tried a few times is getting the
Redirect Permanent / https://my.domain.com
But it just seems to get into a loop of never loading http or https.
Any hints, tips or tricks would be amazing.
Thanks for everyone help! |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Fri 14 Jan '11 0:04 Post subject: |
|
|
I guess you have two vhosts. One with SSL and the other one without. Put that redirect into the non ssl vhost config and not into a .htaccess file or so.
If that doesn't work for you, you can also use mod rewrite to manage that.
Code: |
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
|
I recommend to use the simple redirect in the non ssl vhost (-: |
|
Back to top |
|
kcatta
Joined: 13 Jan 2011 Posts: 3
|
Posted: Fri 14 Jan '11 15:51 Post subject: |
|
|
Thanks for the responce James, I currently have just 1 vhost listed in the vhost.conf and it's for the ssl. But I did notice when changing the setting in the ssl.conf all of the settings I had in the vhost file were also in the ssl file.
Can I comment out the include for the vhost file if I just want the site to be only ssl?
I don't think I have a .htaccess file so I'm not sure I know what you mean about that.
Sorry like I said this is all by the seat of my pants! Thanks again for any input. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Fri 14 Jan '11 16:07 Post subject: |
|
|
Well I don't think it is a good idea to run apache only wiht ssl. Cuase when someone just type example.com in his browser it won't connect since the browser doesn't choose ssl by default. |
|
Back to top |
|
kcatta
Joined: 13 Jan 2011 Posts: 3
|
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Sat 15 Jan '11 18:53 Post subject: |
|
|
Yepp inside that vhost you can set that redirect.
There is a little typo in your config. ServerName should be without www. else if would make no sense to have an ServerAlias. |
|
Back to top |
|