Redirects and response codes · Redirects
JavaScript redirect
The page redirects using JavaScript, which only works once the page is rendered.
How this page is built
A script in the head of this page sends visitors to the redirect destination. Crawlers that do not render JavaScript see this page with a 200 status code. This page redirects immediately; view the source to read it.
Why it matters
A JavaScript redirect only works once the page has been rendered. Search engines that render pages will usually follow it, but they have to fetch and run the page first, which is slower.
Crawlers and tools that do not run JavaScript see a normal page with a 200 status code, so they report the wrong content and miss the move.
How to check it
Fetch the page with JavaScript turned off, or with a command-line tool such as curl, and compare it with what happens in a normal browser. Crawl tools with JavaScript rendering report the redirect. Searching the page source for window.location usually finds the code responsible.
How to fix it
Replace JavaScript redirects with server-side 301 or 302 redirects wherever possible.
If a client-side redirect is unavoidable, use window.location.replace so the old page is not kept in the browser history, and keep the redirect as early in the page as you can.