Forum Academy Marketplace Showcase Pricing Features

How can I auto redirect users if they type in a capitalized URL slug?

Hi there!
Total noob here; appreciate the input.

In the app that I’m building, we expect to get lots of users who will type our web site address on the browser + /whateverpage - however, I’ve just noticed that if users type in URLs capitalized, the slug is not recognized and at least on the dev version, not redirected. So my question is:

When users type www.myapp.com/WHATEVERPAGE, how can I auto redirect them to www.myapp.com/whateverpage instead of a 404?

Thanks
Fabi

You can add the free Toolbox plugin and use Run Javascript action on page load of the 404 page. Here you can put this:

window.location.href = This url :lowercase

I would probably add a conditional to only do it if

Do a search for Thing (where slug equals This url :split by ("/") : last item :lowercase ) first item is not empty

Thanks @williamtisdale - but I can’t seem to make it work. I go to Workflows and create an action on page load and set it up with “This url :lowercase” dynamically, and nothing happens.

I did get the following code to work in that it changes the URL to lowercase, but it proceeds to refresh the page in an infinite loop.

   var oldUrl = window.location.href; 
    var newUrl = oldUrl.toLowerCase(); 
    location.href = newUrl;

Any ideas?

Actually I just realized the url would have changed to your 404 page url. Maybe check and see if there is any way to access the url that caused being directed to the 404 page. That will be the ticket.