JavaScript-Based Redirects Detected
JavaScript-based redirects were detected on 3 pages using inline scripts like window.location.href or window.location.replace.
By Seoxpert Editorial · Published
Why it matters
Search engines may not reliably follow JavaScript redirects because they require script execution, unlike server-side redirects. This can lead to the wrong URLs being indexed or link equity not being properly transferred, negatively affecting SEO performance.
Impact
Unresolved JavaScript redirects can cause incorrect URLs to be indexed and loss of link equity.
How it's detected
An automated crawler scans for inline scripts using redirect patterns such as window.location.href, window.location.replace, or window.location.assign.
Common causes
- Using window.location in inline scripts for navigation or redirection
- Migrating pages without updating to server-side redirects
- Implementing redirects based on client-side logic only
- Lack of awareness about SEO impact of JS redirects
How to fix it
Code examples
Problem: JavaScript Redirect in Inline Script
<script>
window.location.href = '/new-page';
</script>Fix: Server-side Redirect in .htaccess (Apache)
Redirect 301 /old-page /new-pageFix: Next.js Redirect in next.config.js
// next.config.js
module.exports = {
async redirects() {
return [
{
source: '/old-page',
destination: '/new-page',
permanent: true,
},
];
},
};FAQ
Why are JavaScript redirects a problem for SEO?
Search engines may not execute JavaScript, so they can miss or ignore JS-based redirects, causing indexing issues.
Can Googlebot follow JavaScript redirects?
Googlebot may execute JavaScript, but it is not guaranteed or consistent, so server-side redirects are more reliable.
What is the best way to implement redirects for SEO?
Use server-side HTTP 301 (permanent) or 302 (temporary) redirects to ensure search engines properly follow and index the destination URL.
What if my redirect logic depends on client-side state?
If client-side logic is required, ensure the canonical tag on the page always points to the correct target URL.
Found this issue on your site?
Run a scan to see if JavaScript-Based Redirects Detected affects your pages.
Scan my website →