PDA

View Full Version : Enforce www Prefix for SSL


millsy007
11-24-2009, 05:00 PM
Hi

I am using secure socket layer on the checkout pages of my site.

This works fine when a user goes on http://www.example.com/checkout.aspx

However when I was testing my site I went on http://example.com/checkout.aspx the user gets the security warning in the browser about the certifcate not matching.

Is there therefore a way to enforce the www. part of the address for my checkout page. The code I currently have for the ssl is:

protected void Page_Load( object sender , EventArgs e )
{
if (!Request.IsSecureConnection)
{
Response.Redirect(base.UrlBaseSSL);
}

}

public string UrlBaseSSL
{
get { return Request.Url.AbsoluteUri.Replace( @"http://" , @"https://" ); }
}

SouthwaterDave
12-05-2009, 12:40 PM
The problem, I think, is that you have a certificate for www.example.com (http://www.example.com) but you have changed the url to only contain example.com (missing the www).

You will need to beef up your Page_Load() code to correct this as well as the secure connection.