You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Jeffrey Williams <je...@sailorfej.net> on 2007/04/12 11:15:59 UTC

[users@httpd] url rewrite to fix ssl issue with aliased domain name

my dns is set up with my domain name cnamed to my webserver e.g.

mydomain.com IN CNAME www.myname.com

my server is also running a wildcard cert for my domain.

Now when people come to the site by following a link for 
www.mydomain.com, or type www.mydomain.com in the address bar, all is 
good with the world.

However if they follow link for mydomain.com, or type mydomain.com, they 
get a certname does not match hostname error. (apparently wildcard certs 
don't work for domain names without a subdomain or hostname prepended)

Anyway I have tried to use rewrite rules to fix this following are the 
two forms I tried:

RewriteCond "%{HTTP_HOST}" "^mydomain\.com" [NC]
RewriteRule "^/(.*)" "http://www.mydomain.com/$1" [R]

and

RewriteCond "%{HTTP_HOST}" "!^www\.mydomain\.com" [NC]
RewriteCond "%{HTTP_HOST}" "!^$"
RewriteRule "^/(.*)" "http://www.mydomain.com/$1" [R]

neither seems to work, the address bar still shows mydomain.com without 
the www. and the cert warning still shows that the requested hostname as 
mydomain.com without the www.

by the way I have about a dozen other rewrite rules all following these 
ones that seem to be working ok.

any suggestions as to what I am doing wrong, or another way to solve 
this problem, would be appreciated.

Thanks,
Jeff

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] url rewrite to fix ssl issue with aliased domain name

Posted by Joshua Slive <jo...@slive.ca>.
On 4/12/07, Jeffrey Williams <je...@sailorfej.net> wrote:
> my dns is set up with my domain name cnamed to my webserver e.g.
>
> mydomain.com IN CNAME www.myname.com
>
> my server is also running a wildcard cert for my domain.
>
> Now when people come to the site by following a link for
> www.mydomain.com, or type www.mydomain.com in the address bar, all is
> good with the world.
>
> However if they follow link for mydomain.com, or type mydomain.com, they
> get a certname does not match hostname error. (apparently wildcard certs
> don't work for domain names without a subdomain or hostname prepended)
>
> Anyway I have tried to use rewrite rules to fix this following are the
> two forms I tried:

I don't think this is really possible, because the redirect won't
happen until after the SSL negotiation (and certificate warning). If
you accept the certificate, are you seeing the redirection happen? If
not, you should also check to make sure the RewriteRules are inside
the relevant <VirtualHost>s or that you have RewriteOptions inherit
and RerwiteEngine On in the <VirtualHost>s.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] url rewrite to fix ssl issue with aliased domain name

Posted by Jeffrey Williams <je...@sailorfej.net>.
I was under the impression that you can't Redirect match on a requested 
hostname, you redirect to a explicit hostname, but you can't test for 
it, for instance

Redirect /some/path http://otherhost.mydomain.com/some/path

will work, were as

Redirect http://mydomain.com/ http://otherhost.mydomain.com/

won't work.

I am wrong about this?

Thanks
Jeff

POLONKAI Gergely wrote:
> Maybe you should use the Redirect or RedirectMatch directive instead of 
> mod_rewrite. It's considered to be faster, I haven't measured yet however.
> 
> Gergely POLONKAI
> 
> Jeffrey Williams írta:
>> my dns is set up with my domain name cnamed to my webserver e.g.
>>
>> mydomain.com IN CNAME www.myname.com
>>
>> my server is also running a wildcard cert for my domain.
>>
>> Now when people come to the site by following a link for 
>> www.mydomain.com, or type www.mydomain.com in the address bar, all is 
>> good with the world.
>>
>> However if they follow link for mydomain.com, or type mydomain.com, 
>> they get a certname does not match hostname error. (apparently 
>> wildcard certs don't work for domain names without a subdomain or 
>> hostname prepended)
>>
>> Anyway I have tried to use rewrite rules to fix this following are the 
>> two forms I tried:
>>
>> RewriteCond "%{HTTP_HOST}" "^mydomain\.com" [NC]
>> RewriteRule "^/(.*)" "http://www.mydomain.com/$1" [R]
>>
>> and
>>
>> RewriteCond "%{HTTP_HOST}" "!^www\.mydomain\.com" [NC]
>> RewriteCond "%{HTTP_HOST}" "!^$"
>> RewriteRule "^/(.*)" "http://www.mydomain.com/$1" [R]
>>
>> neither seems to work, the address bar still shows mydomain.com 
>> without the www. and the cert warning still shows that the requested 
>> hostname as mydomain.com without the www.
>>
>> by the way I have about a dozen other rewrite rules all following 
>> these ones that seem to be working ok.
>>
>> any suggestions as to what I am doing wrong, or another way to solve 
>> this problem, would be appreciated.
>>
>> Thanks,
>> Jeff
>>
>> ---------------------------------------------------------------------
>> The official User-To-User support forum of the Apache HTTP Server 
>> Project.
>> See <URL:http://httpd.apache.org/userslist.html> for more info.
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 
> 

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] url rewrite to fix ssl issue with aliased domain name

Posted by POLONKAI Gergely <po...@w00d5t0ck.info>.
Maybe you should use the Redirect or RedirectMatch directive instead of 
mod_rewrite. It's considered to be faster, I haven't measured yet however.

Gergely POLONKAI

Jeffrey Williams írta:
> my dns is set up with my domain name cnamed to my webserver e.g.
>
> mydomain.com IN CNAME www.myname.com
>
> my server is also running a wildcard cert for my domain.
>
> Now when people come to the site by following a link for 
> www.mydomain.com, or type www.mydomain.com in the address bar, all is 
> good with the world.
>
> However if they follow link for mydomain.com, or type mydomain.com, 
> they get a certname does not match hostname error. (apparently 
> wildcard certs don't work for domain names without a subdomain or 
> hostname prepended)
>
> Anyway I have tried to use rewrite rules to fix this following are the 
> two forms I tried:
>
> RewriteCond "%{HTTP_HOST}" "^mydomain\.com" [NC]
> RewriteRule "^/(.*)" "http://www.mydomain.com/$1" [R]
>
> and
>
> RewriteCond "%{HTTP_HOST}" "!^www\.mydomain\.com" [NC]
> RewriteCond "%{HTTP_HOST}" "!^$"
> RewriteRule "^/(.*)" "http://www.mydomain.com/$1" [R]
>
> neither seems to work, the address bar still shows mydomain.com 
> without the www. and the cert warning still shows that the requested 
> hostname as mydomain.com without the www.
>
> by the way I have about a dozen other rewrite rules all following 
> these ones that seem to be working ok.
>
> any suggestions as to what I am doing wrong, or another way to solve 
> this problem, would be appreciated.
>
> Thanks,
> Jeff
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server 
> Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org