Add www prefix to URL

百般思念 提交于 2019-12-12 03:21:57

问题


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.

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.

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?

Your help is greatly appreciated.

Thanks.


回答1:


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.



来源:https://stackoverflow.com/questions/9885581/add-www-prefix-to-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!