how do I redirect 80 to 443?

Title says it all. I set up 2 sites on 80 and 443 under the web services panel. On the port 80 site I added a redirect on the Aliases panel ...

"Redirect / https://domain.org"

... but the only URL that redirects is the root:
- http://domain.com will redirect to https://domain.com
- http://domain.com/groups/ will NOT redirect to https://domain.com/groups/

I want all requests to port 80 to be diverted to 443.
-Thanks!

Apple Xserve, Mac OS X (10.5.6)

Posted on May 8, 2009 2:49 PM

Reply
10 replies

May 9, 2009 11:17 PM in response to jisdweb

That's simple - your request tells Apache that only the top URL / should get redirected, which is exactly what's happening.

Your redirect needs to be more like:

Redirect /* https://domain.org/


This will redirect any URL to the https site. If you want to redirect all URLs to the equivalent page on the https site (e.g. /some.html -> https://domain.org/some.html) rather than to the top page, then use something like

Redirect ^/(*)$ https://domain.org/$1


This will capture the original URI and append it to the redirect.

Aug 18, 2009 9:43 AM in response to Camelot

I had to step away from this project for a while. Now that I'm back at it, it seems the issue is persisting even with the "Redirect" in place.

In Server Admin under Web->Sites I have 2 items:
*- domain.com xxx.xxx.xxx.xxx 443*
*- domain.com xxx.xxx.xxx.xxx 80*

under "Aliases" with the port 80 site selected, I have three default alliases ("collab, icons...") and the following:

+Redirect ^/(*)$ https//domain.com/$1+

When I go to the root on port 80, I DO get a homepage but no Groups are listed, instead there is a message that "Group Wikis and Blogs are currently disabled..."

Is there something else that needs to be in place to make the redirect work?

Oct 6, 2009 9:58 AM in response to jisdweb

I found another way around this that might work for you. If what you want is for all traffic to be funneled into the HTTPS site, but to respect the requested link, try this:

1. Open /etc/apache2/sites/0000 any_80.conf (or equivalent)
2. Find a section enclosed by:
<IfModule mod_rewrite.c>
</IfModule>
If you don't see such a section, create one.
3. Add the following code exactly as written here:
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER NAME}%{REQUESTURI} [L,R]
4. Save and restart Apache.

This will cause any request not coming in on port 443 to be rewritten just as it is, but using SSL instead.

Oct 17, 2009 9:37 AM in response to jisdweb

To redirect all http requests to https via Server Admin for OS X Server 10.6.1, do the following:

1. Create a new Site for port 80 (Server Admin>Web>Sites>Add (+))
2. Click Enabled
3. Enter the same host name as the site on port 443, e.g. web.pretendco.com
4. Click the Aliases tab for the port 80 site
5. Delete (the (-)) all URL Aliases and Redirects for the port 80 site
6. Click Add (the (+)) URL Aliases and Redirects for the port 80 site
7. Select Type: RedirectMatch
8. Enter Pattern: (.*)
9. Enter Path: https://<website URL>, e.g. https://web.pretendco.com
10. Click Save

I have not tested this with OS X Server 10.5, but it should be the same.

Oct 29, 2009 6:44 PM in response to jisdweb

I had one subdomain redirecting and then I set up the second one.. and it all went buh-bye..

I have one site - main.mydomain.com

My goal today was to setup a redirect of 80 to 443, and as well I wanted to create an easy link to access the webmail. So, I started off by adding a CNAME record ( webmail ) to my DNS records with GoDaddy to point to my server's A hostname for the webmail redirect.

I then went into Server Admin and setup webmail.mydomain.com first. I created a new site, gave it the hostname webmail.mydomain.com, then created a web server alias for it - webmail.mydomain.com - and then added a redirect ( pattern: webmail.mydomain.com & path: https://main.mydomain.com/webmail/ ) Testing this in Safari redirected webmail.mydomain.com to my secure webmail login page as intended.

I then went back to Server Admin to set up the second redirect for the main site 80 to 443- exactly as I did the first redirect. I created another site and gave it the same hostname as the main domain - main.mydomain.com - added a web server alias for it - main.mydomain.com - and then added the redirect ( pattern: main.mydomain.com & path: https://main.mydomain.com). Testing this in Safari, I was unable to load the 443 page. It found nothing. So I retested the first one, and it no longer worked.

What did I do wrong? I can't seem to get this set up. Anyone?

Jan 12, 2010 12:33 PM in response to jisdweb

This is how I got it to work using Server Admin in Snow Leopard Server (10.6.2):

1) start with a working HTTPS website assigned to port 443 - https://myserver.example.com
2) create a website with the same name on port 80 - http://myserver.example.com
3) in Server Admin's "Aliases" panel, remove all of the default aliases - they are not needed.
4) add this redirect: RedirectMatch ^/(.*)$ https://myserver.example.com/$1

This will redirect any request (including subdirectories) for http://myserver.example.com to https://myserver.example.com.

So, http://myserver.example.com/groups will get redirected to https://myserver.example.com/groups.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

how do I redirect 80 to 443?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.