Skip to main content

Redirecting Subpages to an External Site (301 Redirect Alternative + Workaround)

A practical workaround for redirecting subpages to external URLs using JavaScript when 301 redirects are not supported, allowing users to be automatically forwarded to the correct destination.

Written by Charlene
Updated today

In an ideal setup, redirecting a subpage (e.g. yourdomain.com/page) to an external website should be done using a 301 redirect. A 301 redirect is a server-side instruction that permanently sends users and search engines to a new URL.

However, in some platforms (like static site builders, CMS layers, or Notion-based sites such as Super-style setups), true server-side 301 redirects for individual subpages are not always supported.

When that’s the case, you can use a JavaScript-based redirect workaround.

Important Limitation

A JavaScript redirect:

  • Works for users (browser-based redirect)

  • Is NOT a real 301 redirect

  • May not pass full SEO authority like a server-side redirect

So while it solves navigation issues, it is not a full replacement for SEO-grade redirects.

Workaround: JavaScript Redirect for Subpages

You can add this script inside the page’s custom code section (header or footer depending on your setup):

<script>
(function () {
// Change this to your destination URL
var targetUrl = "https://external-site.com";

// Optional: small delay (helps avoid flicker in some systems)
setTimeout(function () {
window.location.replace(targetUrl);
}, 100);
})();
</script>

Alternative Version (Instant Redirect)

If you don’t want any delay:

<script>
window.location.replace("https://external-site.com");
</script>

Optional: Path-Based Redirect Logic

If you are applying this across multiple subpages and want conditional redirects:

<script>
(function () {
var path = window.location.pathname;

if (path === "/old-page") {
window.location.replace("https://external-site.com/new-page");
}

if (path === "/another-page") {
window.location.replace("https://external-site.com/another");
}
})();
</script>

Did this answer your question?