删除“WWW”在ASP.NET MVC 1.0 [英] remove 'WWW' in ASP.NET MVC 1.0

查看:112
本文介绍了删除“WWW”在ASP.NET MVC 1.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图迫使域名不能使用WWW。我想,如果试图将用户重定向。我已经很少见到的一个MVC的解决方案。反正是有利用内置MVC路由,或者什么是最好的解决方案是。

I am attempting to force the domain name to not use the 'www'. I want to redirect the user if attempted. I have seen very little on an MVC solution. Is there anyway to harness the routing built into MVC, or what the best solutions is.

感谢

推荐答案

如果你有控制的服务器上,你应该建立一个接受请求www.domain.com的虚拟目录,并永久重定向(301)他们为domain.com

If you have control over the server, you should set up a virtual directory that accepts requests for "www.domain.com" and permanently redirects (301) them to "domain.com"

虽然这可能是的可能的ASP.NET MVC中,它不是ASP的工作要做这种重定向的。

While this may be possible in ASP.NET MVC, it is not ASP's job to do this sort of redirecting.

在IIS:

On IIS:

在Apache的:

<VirtualHost *:80>
    ServerName www.domain.com
    Redirect permanent / http://domain.com/
</VirtualHost>

无论是IIS和Apache设置将preserve的URL干。

Both the IIS and the Apache settings will preserve the URL stem.

这篇关于删除“WWW”在ASP.NET MVC 1.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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