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:

* redirecting people away from a discontinued server
* load balancing
* redirecting to error pages if a discontinued URL is used
* link use tracking, as done at the AltaVista search engine
* spamdexing
* ensuring old links and bookmarks still work when a page is renamed
* allowing users to use an abbreviated URL in place of a longer (perhaps less memorable) one

## 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 uses only URLs for external sources. Please consider converting them to the standard citations to ensure the article meets the HandWiki citation style. (2021) (Learn how and when to remove this template message)

|

This article does not cite any external source. HandWiki requires at least one external source. See citing external sources. Please help improve this article. Unsourced material may be removed in future.
Find sources: "Server-side redirect" – news · newspapers · books · scholar · JSTOR (2021) (Learn how and when to remove this template message)

|

0.00

(0 votes)

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Software:Server-side_redirect&oldid=803381"