1

I need to redirect the user to my blog which is in ../blog

When the user types in www.website.com it should load the blog which is in www.website.com/blog

I have a default.aspx page in the root which i no longer use and I have tried added a web.config file in the root with the following to redirect the user to the blog but its not working:

<configuration>
  <location path="blog/default.aspx">
    <system.webServer>
      <httpRedirect enabled="true" destination="http://www.website.com/blog/Default.aspx" httpResponseStatus="Permanent" />
    </system.webServer>
  </location>
</configuration>

What would be the fastest way to redirect the user, I thought about getting rid of my own redundant default.aspx page and creating a new page and using JavaScript to redirect. But which method is the easiest and fastest?

PriceCheaperton
  • 5,071
  • 17
  • 52
  • 94
  • I'm no expert, but it looks like you are redirecting from `blog/Default.aspx`; shouldn't that be `/Default.aspx`? – fguchelaar Mar 01 '13 at 10:40
  • Oh I see what you are saying. I will change it and see if it makes a difference. – PriceCheaperton Mar 01 '13 at 10:43
  • I have just realised that adding another web.config in the root stops the blog working... strange behaviour. Looks like ill go for the meta tag solution in a new default page! – PriceCheaperton Mar 01 '13 at 10:49

2 Answers2

0

use meta tag . For More Info on Meta Tag.

<meta http-equiv="refresh" content="2;url=yourUrl">

in c# From This Answer.

var keywords = new HtmlMeta { Name = "keywords", Content = "one,two,three" };
                Header.Controls.Add(keywords);
Community
  • 1
  • 1
Ravi Gadag
  • 15,735
  • 5
  • 57
  • 83
  • Thanks Ravi, the meta tag solution is a bit slow, it seems to load the old home page then redirect. Do you think I should make a new default.htm page, would it be faster then? – PriceCheaperton Mar 01 '13 at 10:48
0

There are countless ways to do this:

In your old default.aspx:

<meta http-equiv="refresh" content="0;url=/blog/default.aspx">

(note the 0 for zero (or close to zero) delay time)

The same in .Net, might be a bit faster:

Either:

Server.Transfer("~/blog/default.aspx"); //Browser doesn't see new URL

or

Response.Redirect("~/blog/default.aspx");

Or catching all attempts to access pages outside of /blog in your global.asax.cs Application_BeginRequest event. You need to have .Net set as your default interpreter for all pages for this one. This would be overkill though, in my opinion.

  • Accepted as this was the better answer. Nothing personal to the other guy Ravi... Cheers for your help and explanation my friend. – PriceCheaperton Mar 01 '13 at 11:16