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?

4

2 回答 2

0

使用元标记。有关元标记的更多信息。

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

在 c# 中来自这个答案。

var keywords = new HtmlMeta { Name = "keywords", Content = "one,two,three" };
                Header.Controls.Add(keywords);
于 2013-03-01T10:37:56.237 回答
0

有无数种方法可以做到这一点:

在您的旧 default.aspx 中:

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

(注意 0 表示零(或接近零)延迟时间)

.Net 中的相同,可能会更快一些:

任何一个:

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

或者

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

或者在 global.asax.cs Application_BeginRequest 事件中捕获所有访问 /blog 之外页面的尝试。您需要将 .Net 设置为该页面所有页面的默认解释器。不过,在我看来,这将是矫枉过正。

于 2013-03-01T11:12:18.770 回答