简体   繁体   English

在ASP.NET网站中重写URL

[英]url rewriting in asp.net website

I have an asp.net C# website its url is like abc.com so when the website is loaded for the first time its url that appears is abc.com 我有一个asp.net C#网站,其网址类似于abc.com,因此,在首次加载该网站时,其显示的网址是abc.com

But when i visit any other page and come backs to the home page its url become abc.com/home.aspx. 但是,当我访问任何其他页面并返回到主页时,其URL变为abc.com/home.aspx。

But i want it to be the same ie abc.com means i want that the url that appears when the website is loaded for the first time and the url that appears for the home page after visiting any other page should be same. 但是我希望它是相同的,即abc.com意味着我希望第一次加载该网站时出现的URL和访问任何其他页面后显示在主页上的URL应该相同。

I think url rewriting will be used here but i am not sure neither i have any knowledge how to use it so please help. 我认为这里将使用url重写,但是我不确定我也不知道如何使用它,因此请帮忙。

By default this happens because of Default Document feature.. You can read about more from http://www.iis.net/learn/web-hosting/web-server-for-shared-hosting/default-documents link. 默认情况下,由于“默认文档”功能而发生这种情况。您可以从http://www.iis.net/learn/web-hosting/web-server-for-shared-hosting/default-documents链接中了解更多信息。

However once you open us the website abc.com and when you navigate it will surely show you the page name like www.abc.com/home.aspx 但是,一旦打开我们的网站abc.com,当您浏览时,它肯定会为您显示页面名称,例如www.abc.com/home.aspx

And thus what you are looking for seems not possible. 因此,您正在寻找的东西似乎不可能。

You can use link tag marking the canonical in the header of the page. 您可以使用链接标记在页面标题中标记规范。 So, in abc.com/home.aspx you can generate the link tag that tells crawlers that this is a duplicate of abc.com and dont crawl it. 因此,在abc.com/home.aspx中,您可以生成链接标记,该标记告诉爬网程序这是abc.com的副本,并且不要对其进行爬网。

Here are more reference regarding the same subject: http://www.seomoz.org/blog/which-page-is-canonical http://guyellisrocks.com/coding/adding-a-canonical-link-element-in-asp-net/ 以下是有关同一主题的更多参考: http : //www.seomoz.org/blog/which-page-is-canonical http://guyellisrocks.com/coding/adding-a-canonical-link-element-in- ASP / NET /

If you see your home page when you visit abc.com it looks like your default page is set in place. 如果您在访问abc.com时看到主页,则好像默认页面已设置到位。

You can easily redirect user to "/" and it probably will be enough 您可以轻松地将用户重定向到“ /”,这可能就足够了

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

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