need help on setting up redirects if the url has /pages/ in it and is browse using mobile they will be redirected to the following path like this.
google.com/pages/tutorial TO google.com/a/b/pages/tutorial
Here's my code below:
<script type="text/javascript">
if (screen.width <= 699 && url = "pages") {
document.location.href = '' '/a/s' window.location.pathname;
}
</script>
CodePudding user response:
Would something like this achieve your goal?
if (document.location.href.includes("pages"))
document.location.href = document.location.href.replace("pages", "a/b/pages");
CodePudding user response:
Expanding on @async awiat's answer, the following will also check the screen width.
if (screen.width <= 699 && document.location.href.includes("pages")) {
document.location = "name-of-path";
}