Our ASP application is moving to a new server and I want to implement a permanent URL redirection. I am aware of the following two approaches, but I need to understand which one to use and when.
Option 1:
<%@ Language=VBScript %><% Response.Redirect "http://www.example.com" %>
Option 2:
<%@ Language=VBScript %><% Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www.example.com/" %>
Thanks,
Nikhil.
Response. Redirect() should be used when: we want to redirect the request to some plain HTML pages on our server or to some other web server. we don't care about causing additional roundtrips to the server on each request. we do not need to preserve Query String and Form Variables from the original request.
The Response. Redirect method redirects a request to a new URL and specifies the new URL while the Server. Transfer method for the current request, terminates execution of the current page and starts execution of a new page using the specified URL path of the page.
The HyperText Transfer Protocol (HTTP) 301 Moved Permanently redirect status response code indicates that the requested resource has been definitively moved to the URL given by the Location headers. A browser redirects to the new URL and search engines update their links to the resource.
Response.Redirect issues a 302, which is a temporary redirect. 301, using the Response.AddHeader that you listed, is for permanent redirects.
The differences between 301 and 302 have some importance with search-engine-optimization. A 301 will hold all of your search rankings from the old location. On the flip side, if you DON'T want your new page to be indexed, you can use a Response.Redirect (302) since the engines will consider the redirect temporary. Google doesn't index 302's because a lot of spammers use it to try to increase their rankings.
Since you're permanently moving to a new server, a 301 is the best way to go.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With