Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Response Redirect https//domain.com to https://secure.domain.com

Posted on 2013-01-22
Medium Priority
Last Modified: 2013-02-04
My website is built in asp.net 2.0 and C#. my main website is www.domain.com and my secured checkout process is under secure.domain.name

I noticed today that google was indexing some of my products under https://domain.com/prodcuts.aspx?catid=2&prodid=19 instead of https://secure.domain.com/prodcuts.aspx?catid=2&prodid=19. mostly due to relative linking by the developer.

IS there anyway I can rediect the above url to either https://secure.domain.com/products.aspx?catid=2&prodid=19.

and in general anything that starts with https://domain.com to https://secure.domian.com

basically I need to append secure infront of domain.com

any advice or example is highly appreciated

Question by:niceoneishere
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 16

Assisted Solution

by:Rose Babu
Rose Babu earned 2000 total points
ID: 38808803

if you have a master page or a common header control then use the below code in that

protected void Page_Init(object sender, EventArgs e)
	HttpContext context = HttpContext.Current;
	string redirectUrl = null;

		// https://domain.com will be replaced with https://secure.domian.com
		if (context.Request.Url.ToString().StartsWith("") == true)
			redirectUrl = context.Request.Url.ToString().Replace("https://domain.com", "https://secure.domian.com");

		if (redirectUrl != null)
	catch (Exception ex)
		context.Response.Redirect(redirectUrl, false);

Open in new window

This code will redirect all your https://domain.com to https://secure.domian.com

or you may use the same code in the necessary pages alone like abc.aspx, etc...

Try this... Hope this will help you a lot.
LVL 16

Expert Comment

by:Kamal Khaleefa
ID: 38809050
use URL Rewrite module in the IIS itself
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 38809878
Thanks  srosebabu, what am i supposed to put under StartsWith().

Appreciate it
LVL 16

Accepted Solution

Rose Babu earned 2000 total points
ID: 38813189
Oh.. My Mistake... ;-)

Update like this...

if (context.Request.Url.ToString().StartsWith("https://domain.com") == true)

Author Closing Comment

ID: 38851383

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question