加上www preFIX到URL [英] Add www prefix to URL

查看:171
本文介绍了加上www preFIX到URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.Net MVC 3网站托管在一个共享的Windows主机包。我希望我的站点自动添加的wwwpreFIX我所有的网站页面,当用户不输入它,也就是说,mytestpage.com重定向到www.mytestpage.com。

I have an ASP.Net MVC 3 Website hosted on a shared Windows hosting package. I wish for my site to automatically add a 'www' prefix to all my site pages when the user does not type it in, ie, mytestpage.com redirects to www.mytestpage.com.

我已经经历了#1和其他互联网网站浏览广泛找到一个解决这个,但无济于事。给出的解决方案是要么配置IIS本身,但是,我没有,因为我使用的是共享主机包访问IIS。

I have browsed extensively through Stackoverflow and other Internet sites to find a solution to this, but to no avail. The solutions given are to either configure IIS itself, however, I do not have access to IIS as I am using a shared hosting package.

还有人说,通过Web配置文件的 IIS7 URL重写 - 新增] WWW"然而,preFIX 这似乎只与IIS 7的工作。

Others have said to add the prefix via the web config file IIS7 URL Rewrite - Add "www" prefix however this seems only to work with IIS 7.

有没有其他方法可以让我做到这一点?

Is there any other way I can achieve this?

您帮助是极大的AP preciated。

Your help is greatly appreciated.

感谢。

推荐答案

在我的解决方案,我在应用程序启动检查请求是否有WWW或没有。如果没有,我重定向到www。

On my solutions I do a check on Application Start whether the request has www or not. If not, I redirect to www.

和我所有的链接都是相对的,当然。

And all my links are relative, of course.

这篇关于加上www preFIX到URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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