Server-side redirect

A server side redirect is a method of URL redirection using an HTTP status code (e.g., 301 Moved Permanently, 303 See Other and 307 Temporary Redirect) issued by a web server in response to a request for a particular URL. The result is to redirect user's web browser to another web page with a different URL.

One method of implementing server-side redirects is the .htaccess file supported by most Apache web servers. An example of the code used is as follows.

redirect 301 /index.html http://www.example.org/index.html

Common uses of server-side redirects include:

Code

PHP code for server-side redirect.

header("Location: http://www.example.com/");

ASP.NET code for server-side redirect.

Response.AddHeader("Location: http://www.example.com/");

Implementation in JavaServer Pages (JSP).

response.setHeader("Location", "http://www.example.com/");
This article is issued from Wikipedia - version of the Monday, September 14, 2015. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.