简体   繁体   English

重定向301可以正常工作吗?

[英]Redirect 301 works fine?

I added into my global.asax a 301 redirect from subdirectory to root .. www.informarea.it/blogengine to www.informarea.it When I write in browser the name of the site: for example: 我在我的global.asax中添加了从子目录到根目录的301重定向。www.informarea.it/blogengine到www.informarea.it当我在浏览器中编写网站名称时,例如:

www.informarea.it / BlogEngine, the redirect happens perfectly and the link change in www.informarea.it, www.informarea.it/ BlogEngine,重定向发生得很好,并且www.informarea.it中的链接发生了变化,

when i write a old post in browser i dont see the redirect, i see the content of post but the word blogengine is present, 当我在浏览器中写旧帖子时,我看不到重定向,我看到了帖子的内容,但出现了词blogengine,

the same when i go on a referral site and I click on an old post in page appears www.informarea.it/ BlogEngine / prova.aspx and not www.informarea.it / prova.aspx. 在转介网站上并单击页面中的旧帖子时,情况也是如此,而www.informarea.it/ BlogEngine / prova.aspx,而不是www.informarea.it/prova.aspx。 ... the strange is that i see the post... but this is normal? ...奇怪的是我看到了帖子...但这是正常的吗?

then I currently have 1400 and 1000 duplicate description tags duplicate title tags ...... 那么我目前有1400和1000个重复的描述标签,重复的标题标签......

All is normal or there is some error?? 一切正常还是有一些错误?

the code is this.. 代码是这样的。

string thisUrl = app.Request.Url.ToString().ToLower();

if (thisUrl.Contains("http://www.informarea.it/blogengine"))
{

  HttpContext.Current.Response.Status = "301 Moved Permanently";
  HttpContext.Current.Response.StatusCode = 301;
  HttpContext.Current.Response.AddHeader("Location",thisUrl.Replace("http://www.informarea.it/blogengine","http://www.informarea.it"));
}

HttpContext context = app.Context; HttpContext context = app.Context;

can you help me thank you 你能帮我谢谢吗

Fabry 法布里

You need to use a HHTP Module for Redirect instead of in the global. 您需要使用HHTP模块进行重定向,而不是使用全局模块。

Here is a link on how to do that: 这是有关如何执行此操作的链接:

http://www.codeproject.com/Articles/110595/Handling-301-Redirects-in-ASP-NET-3-5 http://www.codeproject.com/Articles/110595/Handling-301-Redirects-in-ASP-NET-3-5

Having the redirect in the global does not really work for directories. 在全局中具有重定向对于目录实际上并不起作用。

Also having it in the http module gets redirected before it hits the global file. 在http模块中也将其重定向到命中全局文件之前。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM