Skip to content
Advertisement

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

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:

JavaScript

In PHP:

JavaScript

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

Advertisement

Answer

You can not do this with JavaScript.

But you can use PHP as follows

JavaScript

Syntax header

header(header, replace, http_response_code)

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement