Internal url redirect

New Member
1 0 0

Hello everyone,

How to redirect all internal url links in one time? For example if i have url:

and I want redirect to: 

that it would be without / 


Shopify Partner
24 3 2

This is an accepted solution.

Have you tried using Shopify's redirects?

Honestly, I've never tried it but my gut feeling is that since /collections/all and /collections/all/ are still in a way the same route, it might just redirect back to itself over and over again on repeat forever. Maybe not though, and it might be worth giving a shot.

There's also a front end solution, but I wouldn't necessarily recommend that you do it. But it works so you can use it if you want. You could use window.location.pathname to do it. Here's a function that would redirect if the pathname ends with a / but only if it's not the homepage because the pathname is always / for the homepage. Just add it as high as possible on the site to prevent the whole page from having to load twice.

  var pathname = window.location.pathname;
  if (pathname && pathname.length > 1 && pathname.charAt(pathname.length - 1) === '/') {
    window.location.pathname = window.location.pathname.slice(0, -1);
Sam Webb