asp.net - Global 301 redirection from domain to www.domain -


could use begin request of global.asax redirect everything,

from mydomain.domain www.mydomain.domain?

if 1 true, how can that?

protected void application_prerequesthandlerexecute(object sender, eventargs e) {   string currenturl = httpcontext.current.request.path.tolower();   if(currenturl.startswith("http://mydomain"))   {     response.status = "301 moved permanently";     response.addheader("location", currenturl.replace("http://mydomain", "http://www.mydomain"));     response.end();   } } 

Comments

Popular posts from this blog

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c# - Making TableLayoutPanel Act Like An HTML Table (Cells That Resize Automatically Around Text) -