logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Getting Apache to redirect http to https...
Author
kcatta



Joined: 13 Jan 2011
Posts: 3

PostPosted: Thu 13 Jan '11 23:32    Post subject: Getting Apache to redirect http to https... Reply with quote

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

PostPosted: Fri 14 Jan '11 0:04    Post subject: Reply with quote

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

PostPosted: Fri 14 Jan '11 15:51    Post subject: Reply with quote

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

PostPosted: Fri 14 Jan '11 16:07    Post subject: Reply with quote

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

PostPosted: Fri 14 Jan '11 17:09    Post subject: Reply with quote

Thanks again James,
So would the idea be to have a second vhost looking at port 80

<VirtualHost www.mydomain.com:80>
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
ServerName www.mydomain.com:80
ServerAlias www.mydomain.com:80
</VirtualHost>

and inside of that VirtualHost I could add the

Redirect Permanent / https://www.mydomain.com

?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Sat 15 Jan '11 18:53    Post subject: Reply with quote

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


Reply to topic   Topic: Getting Apache to redirect http to https... View previous topic :: View next topic
Post new topic   Forum Index -> Apache