remove 'WWW' in ASP.NET MVC 1.0

前端 未结 4 1302
被撕碎了的回忆
被撕碎了的回忆 2021-02-11 04:14

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

4条回答
  •  悲哀的现实
    2021-02-11 04:45

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

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

    On IIS: Virtual Directory

    On Apache:

    
        ServerName www.example.com
        Redirect permanent / http://example.com/
    
    

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

提交回复
热议问题