IIS如何应用ASP.NET中的“默认页面”设置(C#)

时间:2021-04-05 20:54:44

I'm attempting to issue a 301 redirect when a user requests http://www.mysite.com/Default.aspx to http://www.mysite.com/

当用户请求http://www.mysite.com/Default.aspx到http://www.mysite.com/时,我正尝试发出301重定向

The issue I'm having is that every property I can find within Request (Request.Url, Request.RawUrl, etc) is identical for those two requests.

我遇到的问题是我在Request(Request.Url,Request.RawUrl等)中找到的每个属性对于这两个请求是相同的。

Edit for further clarification: This is on a shared web host, I can't install ISAPI extensions.

编辑以进一步说明:这是在共享的Web主机上,我无法安装ISAPI扩展。

One more edit. Apparently the first tech support guy I talked to at the host didn't know what he was talking about, they have ISAPI rewrite installed.

还有一个编辑。显然,我在主持人处理过的第一个技术支持人员并不知道他在说什么,他们已经安装了ISAPI重写。

3 个解决方案

#1


Just use a url rewriting ISAPI filter. It's painless. This page on Scott Gu's blog contains pretty much all the info you need.

只需使用URL重写ISAPI过滤器。这很痛苦。 Scott Gu的博客上的这个页面包含了您需要的所有信息。

#2


Steve Wortham's Blog describes how he addressed the same issue.

Steve Wortham的博客描述了他如何解决同一问题。

He used Ionic's free Isapi Rewrite Filter

他使用了Ionic的免费Isapi Rewrite Filter

#3


Whilst a lot of people cite SEO as the reason for wanting to do this, I'd just like to make a minor observation:

虽然很多人都认为SEO是想要这样做的原因,但我只是想做一个小小的观察:

Search for the word "Welcome" on my site

在我的网站上搜索“欢迎”一词

This word appears on the homepage (default.aspx), and in a blog post. At the moment I'm seeing three results for this search:

这个词出现在主页(default.aspx)和博客文章中。目前我看到了这个搜索的三个结果:

Search results http://www.doodle.co.uk/userfiles/image/site-doodle.png

搜索结果http://www.doodle.co.uk/userfiles/image/site-doodle.png

The middle one is my homepage, and you'll note that it's only listed once - yet you can easily visit, and stay on /default.aspx if you browse to it (and indeed, the navigation on the site links to /Default.aspx).

中间的一个是我的主页,你会注意到它只列出一次 - 但是你可以轻松访问,并且如果你浏览它就会留在/default.aspx(事实上,网站上的导航链接到/ Default。 ASPX)。

If anything it's more of an issue with reporting, as google analytics for example sees /default.aspx and /Default.aspx as different pages (but again, the search results are ignoring casing on a windows server):

如果有什么问题更多的是报告问题,例如谷歌分析将/default.aspx和/Default.aspx视为不同的页面(但同样,搜索结果忽略了Windows服务器上的外壳):

Analytics repeats http://www.doodle.co.uk/userfiles/image/Analytics.png

分析重复http://www.doodle.co.uk/userfiles/image/Analytics.png

So, all I'm saying is that search engines are often brighter than SEO consultants give them credit for...

所以,我所说的只是搜索引擎通常比SEO顾问更加明亮......

A bigger problem for my site is the fact that I have three domain names pointing at it, and still haven't gotten around to putting a redirect inplace for the other ones.

对我的网站来说,一个更大的问题是我有三个域名指向它,并且仍然没有为其他域名重新定位。

#1


Just use a url rewriting ISAPI filter. It's painless. This page on Scott Gu's blog contains pretty much all the info you need.

只需使用URL重写ISAPI过滤器。这很痛苦。 Scott Gu的博客上的这个页面包含了您需要的所有信息。

#2


Steve Wortham's Blog describes how he addressed the same issue.

Steve Wortham的博客描述了他如何解决同一问题。

He used Ionic's free Isapi Rewrite Filter

他使用了Ionic的免费Isapi Rewrite Filter

#3


Whilst a lot of people cite SEO as the reason for wanting to do this, I'd just like to make a minor observation:

虽然很多人都认为SEO是想要这样做的原因,但我只是想做一个小小的观察:

Search for the word "Welcome" on my site

在我的网站上搜索“欢迎”一词

This word appears on the homepage (default.aspx), and in a blog post. At the moment I'm seeing three results for this search:

这个词出现在主页(default.aspx)和博客文章中。目前我看到了这个搜索的三个结果:

Search results http://www.doodle.co.uk/userfiles/image/site-doodle.png

搜索结果http://www.doodle.co.uk/userfiles/image/site-doodle.png

The middle one is my homepage, and you'll note that it's only listed once - yet you can easily visit, and stay on /default.aspx if you browse to it (and indeed, the navigation on the site links to /Default.aspx).

中间的一个是我的主页,你会注意到它只列出一次 - 但是你可以轻松访问,并且如果你浏览它就会留在/default.aspx(事实上,网站上的导航链接到/ Default。 ASPX)。

If anything it's more of an issue with reporting, as google analytics for example sees /default.aspx and /Default.aspx as different pages (but again, the search results are ignoring casing on a windows server):

如果有什么问题更多的是报告问题,例如谷歌分析将/default.aspx和/Default.aspx视为不同的页面(但同样,搜索结果忽略了Windows服务器上的外壳):

Analytics repeats http://www.doodle.co.uk/userfiles/image/Analytics.png

分析重复http://www.doodle.co.uk/userfiles/image/Analytics.png

So, all I'm saying is that search engines are often brighter than SEO consultants give them credit for...

所以,我所说的只是搜索引擎通常比SEO顾问更加明亮......

A bigger problem for my site is the fact that I have three domain names pointing at it, and still haven't gotten around to putting a redirect inplace for the other ones.

对我的网站来说,一个更大的问题是我有三个域名指向它,并且仍然没有为其他域名重新定位。