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++ - Convert big endian to little endian when reading from a binary file -

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

unicode - Are email addresses allowed to contain non-alphanumeric characters? -