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

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -