I am a web developer who also works in SEO. I want to 301 redirect one page to another page. Is this 301 redirect for Google beyond what I write below for you?
<script> window.location.replace("https://example.com"); </script>
<?php header("Location: https://example.com"); ?>
Are these two 301 redirects, or do we have to write
.htaccess in the cat file, for example?
But you can use PHP as follows
<?php header("Location: https://example.com", TRUE, 301); exit; ?>
header(header, replace, http_response_code)
Changing the URL with
200 OK status.
301 Permanent variety compared to JS redirects,
302 Temporary redirects, or meta refreshes.
If you have the ability and opportunity to implement server side
301 Permanent redirects, you should do so instead of JS redirects.