I have several thousand external links that take the form ‘mysite/linkfile.php=a’. Unsurprisingly, they return page not found. What I want to do is create a file called ‘linkfile.php=a’ and use javascript to obtain the file name (they are all different), remove the ‘=a’ part of the file name (this is consistent) and then redirect the user to ‘mysite/linkfile.php’.
Something like:
<script>
function myFunction() {
var url = window.location.pathname; var filename = url.substring(url.lastIndexOf('/')+1);
document.getElementById("newfilename").innerHTML = filename.replace("=r", "");
window.location='https://www.mysite/filename';
}
// -->
</script>
This works OK until the last line, which cannot recognise the result of `filename.replace(“=r”, “”)` in that URL. Is this purely a syntax issue?
I’m a noobie so any help will be gratefully received.