Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is a 301 redirect the same as changing window.location?

I want your answer, yes or no!

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?

In JavaScript:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<script> 
      window.location.replace("https://example.com");
</script> 

In PHP:

<?php 
    header("Location: https://example.com");
?>

Are these two 301 redirects, or do we have to write .htaccess in the cat file, for example?

>Solution :

You can not do this with JavaScript.

But you can use PHP as follows

<?php 
    header("Location: https://example.com", TRUE, 301);
    exit;
?>

Syntax header

header(header, replace, http_response_code)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading