3 domains, 1 hosting account

Using a single web hosting account to host multiple sites

3 domains, 1 hosting account

Postby micsin » Thu Aug 30, 2007 1:42 am

Hi!
Right now I'm changing my Host. The .com domain is still hosted by the old one. My .de & .eu domains are allready transferred to the new one. All domains should point to the .com for some time.

That's how I'ld like to set up...

http://www.example.de
http://example.de
http://www.example.eu
http://example.eu
--> http://example.com

https://www.example.de
https://example.de
https://www.example.eu
https://example.eu
--> https://www.example.com
(My ssl certificate is for www.example.com)

The http redirect works fine but I've problems to set up a redirect for the https.

My .htaccess:

Code: Select all
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule .* http://example.com/? [R=301,L]
#SSL
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteCond %{SERVER_PORT} !^443$
RewriteRule .* https://www.example.com/? [R=301,L]


Any Ideas?
Michael
micsin
 
Posts: 4
Joined: Thu Aug 30, 2007 1:38 am

Postby richardk » Thu Aug 30, 2007 4:00 pm

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

#SSL
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteCond %{SERVER_PORT} ^443$
RewriteRule .* https://www.example.com/? [R=301,L]

RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
RewriteCond %{SERVER_PORT} !^443$
RewriteRule .* http://example.com/? [R=301,L]


If you want to pass the file/directory too, eg. domain.de/abc to domain.com/abc, replace
Code: Select all
RewriteRule .* https://www.example.com/? [R=301,L]

with
Code: Select all
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]

and
Code: Select all
RewriteRule .* http://example.com/? [R=301,L]

with
Code: Select all
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby micsin » Fri Aug 31, 2007 1:09 am

Thanks for your help. Unfortunately it doesn't work for the https redirect.
Firefox tells that he can't establish a connection to the server.

I've found a code which does the https redirect. But only for http -> https. Not https -> https.

Code: Select all
Options +FollowSymLinks
RewriteEngine on
# Skip if requested hostname is canonical (or blank) AND request is https
RewriteCond %{HTTP_HOST} ^$¦^www\.example\.com
RewriteCond %{SERVER_PORT} ^443$
RewriteRule .* - [S=1]
# Else redirect to canonical domain using https
RewriteRule (.*) https://www.example.com/$1 [R=301,L]
micsin
 
Posts: 4
Joined: Thu Aug 30, 2007 1:38 am

Postby richardk » Fri Aug 31, 2007 3:59 pm

Firefox tells that he can't establish a connection to the server.

What happened before? Do the domains normally work with SSL? If they didn't, mod_rewrite can't make them.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby micsin » Mon Sep 03, 2007 5:45 am

I think I found the error.
We only own a SSL certificate for our .com domain not for the other ones...
So we can't redirect a https from our .de to the .com because we have no certificate for the .de domain, right?
micsin
 
Posts: 4
Joined: Thu Aug 30, 2007 1:38 am

Postby richardk » Mon Sep 03, 2007 3:57 pm

So we can't redirect a https from our .de to the .com because we have no certificate for the .de domain, right?

Right. To make an SSL request (to the .de domain) the browser must get the certificate to encrypt it before the redirect can happen.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby micsin » Tue Sep 04, 2007 12:06 am

Thanks for your help!
Michael
micsin
 
Posts: 4
Joined: Thu Aug 30, 2007 1:38 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 9 guests

cron