asp.net - How to redirect all .aspx URLs to their NEW location on a subdomain -
i completed transfer of large aspdotnetstorefront site (many pages/urls) domain's wwwroot subdomain.
for seo reasons want auto 301 redirect & old urls end in ".aspx" new location on subdomain. (all paths being same except being in subdomain instead of wwwroot)
example: old url= "http://www.mysite.com/c-2-some-product-page.aspx"
desired new url = "http://store.mysite.com/c-2-some-product-page.aspx"
i need check if requested page ends in .aspx, redirects "store" subdomain. should make sure requested old page url doesn't exist
this site running on windows host, appliedi.net
thanks much
i think want try in global.asax file
// untested, concept there. private void application_beginrequest(object source, eventargs e) { if (httpcontext.current.request.url.tostring().tolower().startswith( "http://www.mysite.com/")) { httpcontext.current.response.status = "301 moved permanently"; httpcontext.current.response.addheader("location", request.url.tostring().tolower().replace( "http://www.mysite.com/", "http://store.mysite.com/")); } }
Comments
Post a Comment