Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

269
Vistas
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:

<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?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

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)

over 4 years ago · Santiago Trujillo Denunciar

0

Changing the URL with window.location in JavaScript is not a 301 redirect. JavaScript runs after the page has been generated on the server. Your JavaScript to change the URL would likely run on a page that has a 200 OK status.

That being said, Google treats JavaScript redirects very similarly to 301 permanent redirects. In most cases, Google will choose not to index the redirecting URL and pass the link juice from it to the target of the redirect.

On the other hand, clients that don't execute JavaScript won't see your JS powered redirect. That includes other search engines like Bing, Baidu, and Yandex, as well as broken link checkers and other SEO analysis tools.

Furthermore, even to Google, 301 redirects are a much stronger signal than a JavaScript redirect. Google is most likely to honor a redirect when it is a 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.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda