In most cases, server-side domain redirects are carried out via the configuration file, .htaccess, or a PHP script. The advantage these methods offer is that it’s possible to individually define which HTTP status code should be displayed to the user agent. This allows website operators to mark domain redirects as either permanent or temporary. Here, the HTTP status codes 301 and 302 are relevant.
- 301 – Moved Permanently: the requested resource is now permanently available under the redirected URL. The old URL will remain invalid from this point on.
- 302 – Moved Temporarily: the requested resource is available under the redirected URL. Unlike the 301 code, the original URL still remains valid.
If the HTTP status code isn’t explicitly defined, the web server transfers the status code 302 during a server-side redirect. This isn’t always necessary, and it’s recommended to manually enter the desired status code during each redirect, as this helps reduce the chances of indexing errors, like URL hijacking, from occurring. Unlike the 301 redirect, the status code 302 informs web crawlers that the original URL should remain indexed. When intended for permanent operation, the redirect address competes with the redirection destination in the search engine index.