hi!!! so a couple of months ago i switched from neocities to nearlyfreespeech and since i really like it im ready to fully move away from neocities. im trying to set it up so that going from therift.neocities.org/example.html goes to therift.vip/example.html but all the solutions i can find just tell people to use a 301 redirect with htaccess (which i cant do because neocities doesnt support it)
this is what i tried:
<script type="text/javascript">
var restOfTheUrl = domainName.split('therift.neocities.org')[1] || '';
function redirect() { window.location.href = "https://therift.vip/" + restOfTheUrl;}
</script>
<body onload="redirect()"></body>
but it returns the “rest of the url” part as “undefined” as you can see on the page here: https://therift.neocities.org/not_found so theres clearly something missing but i cant tell what.
window.location.pathname is what you’re looking for. For example, '/t/redirecting-to-my-new-domain-with-js/3206' is what that will spit out if you run it on this page
function redirect() { window.location.href = "https://therift.vip" + location.pathname;}