views:

156

answers:

2

I have a site with an SSL cert for www.foo.com. What is the cleanest way redirect requests to the https:// prefix? Do I have to build links server side instead of relying on resolving urls with relative paths, ~/?

Also, say I redirect to an https:// page, the links on the page are all created in a master page and are resolved with relative paths. If the user clicks on any of the navigation elements they are essentially stuck on the https:// path, what is the best way to clean that up?

The paths all need to work in the dev (localhost), staging, and production environments.

A: 

You can set the <base> tag in your html, which would mean everything would then be relative to that base url.

Sohnee
+1  A: 

No you dont need to do anything,

Unless you issue a fully qualified url, your every relative url redirects and paths are always considered along with https:// for example,

Your url of page is https://mysite/folder1/page.aspx and if you issue Response.Redirect("/folder2/page2.aspx") then web server only issues relative url "/folder2/page2.aspx" but the client (IE/FF2/Safari) they append "https://mysite" before the url.

So as long as you use relative urls in your project, you are safe.

Akash Kava