The company I am working with has a main site with an .com
tld, but also own multiple other tld's as .de
and .es
. These other tld's will always redirect using the underneath code. Should I add an 301 Moved Permanently
status code with the redirect or are these status code not important in this case? Or should a status code 204 No Content
be more suitable?
PHP Redirect code:
<?php
header("Location: https://www.google.com");
exit();
?>
You are doing a permanent redirect, so you should use the 301 Moved Permanently status code. This link below explains the codes and why they are important:
A 301 HTTP header is used when the requested URL permanently moved to a new location. As you are working on your site, you will often use this, because you regularly need to make a 301 redirect to direct an old URL to a new one. If you don’t, users will see a 404 error page if they try to open the old URL and that’s not something you want. Using a 301 will make sure that the link value of the old URL transfers to the new URL.