Server-side redirect
Encyclopedia
A server side redirect is a method of URL redirection
URL redirection
URL redirection, also called URL forwarding and the very similar technique domain redirection also called domain forwarding, are techniques on the World Wide Web for making a web page available under many URLs.- Similar domain names :...

 using an HTTP status code (e.g., 301 Moved Permanently, 303 See Other and 307 Temporary Redirect) issued by a web server
Web server
Web server can refer to either the hardware or the software that helps to deliver content that can be accessed through the Internet....

 in response to a request for a particular URL
Uniform Resource Locator
In computing, a uniform resource locator or universal resource locator is a specific character string that constitutes a reference to an Internet resource....

. The result is to redirect user's web browser
Web browser
A web browser is a software application for retrieving, presenting, and traversing information resources on the World Wide Web. An information resource is identified by a Uniform Resource Identifier and may be a web page, image, video, or other piece of content...

 to another web page
Web page
A web page or webpage is a document or information resource that is suitable for the World Wide Web and can be accessed through a web browser and displayed on a monitor or mobile device. This information is usually in HTML or XHTML format, and may provide navigation to other web pages via hypertext...

 with a different URL
Uniform Resource Locator
In computing, a uniform resource locator or universal resource locator is a specific character string that constitutes a reference to an Internet resource....

.

One method of implementing server-side redirects is the .htaccess
.htaccess
A .htaccess file is a directory-level configuration file supported by several web servers, that allows for decentralized management of web server configuration....

 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
    Load balancing
    Load balancing or load distribution may refer to:*Load balancing , balancing a workload amongst multiple computer devices*Load balancing , the storing of excess electrical power by power stations during low demand periods, for release as demand rises*Weight distribution, the apportioning of weight...

  • redirecting to error pages if a discontinued URL is used
  • link use tracking, as done at the AltaVista
    AltaVista
    AltaVista is a web search engine owned by Yahoo!. AltaVista was once one of the most popular search engines but its popularity declined with the rise of Google...

     search engine
    Search engine
    A search engine is an information retrieval system designed to help find information stored on a computer system. The search results are usually presented in a list and are commonly called hits. Search engines help to minimize the time required to find information and the amount of information...

  • spamdexing
    Spamdexing
    In computing, spamdexing is the deliberate manipulation of search engine indexes...

  • 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
PHP
PHP is a general-purpose server-side scripting language originally designed for web development to produce dynamic web pages. For this purpose, PHP code is embedded into the HTML source document and interpreted by a web server with a PHP processor module, which generates the web page document...

 code for server-side redirect.

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


ASP.NET
ASP.NET
ASP.NET is a Web application framework developed and marketed by Microsoft to allow programmers to build dynamic Web sites, Web applications and Web services. It was first released in January 2002 with version 1.0 of the .NET Framework, and is the successor to Microsoft's Active Server Pages ...

 code for server-side redirect.

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


Implementation in JavaServer Pages
JavaServer Pages
JavaServer Pages is a Java technology that helps software developers serve dynamically generated web pages based on HTML, XML, or other document types...

(JSP).

response.setHeader("Location", "http://www.example.com/");
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK