Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

"HTTP Redirection" – the process by which a request for one URL is automatically replaced by a request for a different, usually related, URL.

HTTP Redirection is usually accompanied by a Status Code that reflects the reason for the redirect. Most common are 301 (permanent) and 302 (temporary) redirects. If you're not sure which one to take you probably want a 301.

These are colloquially referred to as "error codes", the most well know being 404, but in fact many are not errors.

Redirection can be triggered in several ways

By the Web Server itself

Modern Web Servers such as Apache (see ) have mechanisms that allow redirects to occur at the level before any other code (such as ) executes. In Apache, this is done via mod_rewrite and .htaccess rules (see . Other servers have similar mechanisms. WordPress uses this feature of the server, in conjunction with its own URL processing, to construct "pretty ".

By Software on the Server

It is possible for software such as WordPress to redirect a request on its own. wp_redirect and wp_safe_redirect are two Core WordPress functions intended for this purpose.

history | excerpt history