有没有办法在网站上始终要求或强制“www”子域名? [英] Is there a way to always require or force the 'www' subdomain on a site?

查看:119
本文介绍了有没有办法在网站上始终要求或强制“www”子域名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想阻止用户说到example.com并且只访问www.example.com,我们正在使用IIS 6.所以说他们去了example.com,它可以在www.example.com上发布,等等。

I want to prevent users from going to say example.com and only go to www.example.com, we are using IIS 6. So say they go to example.com it could tack on the www.example.com, etc.

这是一个设置在某个地方还是我必须编码它来检查子域何时降落并相应地重定向?

Is this a setting somewhere or will I have to code it to check for the subdomain when they land and redirect accordingly?

编辑:我知道最好的方法是远离www前缀,但无论出于何种原因,如果用户启动课程(这是一个LMS)而没有URL中的www,跟踪不适用于.asmx文件,这就是我试图强制'www'的原因,因为如果有人没有它,那么他们想知道为什么跟踪不起作用。

I know the best way is to move away from the www prefix but for whatever reason if the user launches a course (this is an LMS) without the www in the URL the tracking does not work for the .asmx file, that is why I am trying to force the 'www' because if some people don't have it then they wonder why the tracking does not work.

推荐答案

由于两个记录都已指向正确的服务器...

As both records already point to the correct server...

...您可以在IIS中设置一个新网站(需要服务器版本)并让它只响应example.com(主机头设置)并将其重定向到所需的URL(检查重定向)在主目录选项卡中输入网址并输入www.example.com)。然后原始网站应该处理它(你可以设置它的主机头来回答www.example.com更具体)。

...you could simply set up a new website in IIS (server version needed) and have it respond only to example.com (the host header setting) and have it redirect to the wanted url (check redirect to url in Home Directory tab and enter www.example.com). The original site should then handle it (you could set it's host header to answer to www.example.com to be more specific).

如果你做不到在Web服务器上,您的发布防火墙应该能够,或者您可以考虑替换它。您的DNS提供商也可能提供(不打算)重定向服务(基本上与您的上述基本相同)。

If you can't do that on the web server, your publishing firewall should be able to, or you might consider replacing it. Your DNS provider might also provide (pun not intended) a redirect service (doing basically the same thing as above for you I guess).

这篇关于有没有办法在网站上始终要求或强制“www”子域名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆