Complete website in Rs. 5,000 with Free Hosting & Domain. Offer ends in  00:00:00
Back to Blog

How to Redirect Full URL with Parameters with JavaScript

May 16, 2023 Updated: May 16, 2023

Here we are redirecting to example.netlify.app from current domain (where this file is hosted).

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="canonical" href="https://example.netlify.app" />
        <noscript>
            <meta http-equiv="refresh" content=";url=https://example.netlify.app">
        </noscript>
        <title>Example</title>
    </head>
    <body>
        <script type="text/javascript">
            var url = 'https://example.netlify.app' + window.location.pathname;
            var referLink = document.createElement("a");
            referLink.href = url;
            document.body.appendChild(referLink);
            referLink.click();
        </script>
    </body>
</html>
Contact

Got A Question For Us?

Feel free to ask anything directly on call or fill the form and we will contact back within few hours.