[英]Convert URL page extension(.aspx) into HTML(.html)
我想在運行時將隱蔽的aspx頁面轉換為html進行SEO。
像示例localhost:45556 / index.aspx => localhost:45556 / index.html
Google不在乎它是aspx還是html。 更重要的部分是域名告訴您有關網站的內容,URL路徑告訴您有關您所訪問頁面的信息。
與www.domain.com/prodId=3999944相比,www.domain.com / shirts / tshirts / green /是更好的URL
您可以像本文中所述使用IIS重寫模塊:
並將匹配的URl標准更改為
<match url="(.*).html" />
並將操作更改為以下內容
<action type="Rewrite" url="{R:1}.html" />
您可以在c#.NET中將.aspx更改為.html
請將此代碼放在您的Global.asax文件中。
protected void Application_BeginRequest(object sender, EventArgs e)
{
HttpApplication app = sender as HttpApplication;
if (app.Request.Path.ToLower().IndexOf(".html") > 0)
{
string rawpath = app.Request.Path;
string path = rawpath.Substring(0, rawpath.IndexOf(".recon"));
app.Context.RewritePath(path+".aspx");
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.