Problems URL which leads to a 404 page when refreshed (due to special symbols)

Hi guys!

So, I’ve come across an issue where some URL containing special symbols like parenthises, or plus signs, would change when refreshed, leading to a 404 page.

I’d like to specify that the URL is based on the title of the “product” page, and is automatically created.

Here is a link to an example. Click it, and it should work fine. But try hitting F5, and it will lead to a 404 page. You can see that the URL has changed, causing this to happen.

Any idea how to fix this?

https://www.wehaveadeal.net/deals/%5BCDAV%5D-Jeu-Cyberpunk-2077—Edition-Day-One-sur-PS4-%2F-Xbox-One-(%2B20%E2%82%AC-cr%C3%A9dit%C3%A9s)/1607529491

Here is what the URL looks like when refreshed :

https://www.wehaveadeal.net/deals/%5BCDAV%5D-Jeu-Cyberpunk-2077—Edition-Day-One-sur-PS4-%2F-Xbox-One-%28-20%E2%82%AC-cr%C3%A9dit%C3%A9s%29/1607529491

You can see that parentheses were changed to some code.

up

The page URL should be based not on title but on encodeURI(title)

In your case on encodeURIComponent(title)

@jonatandor35 what do you mean? I want the URL to contain the title of the product, to make it look nicer and more transparent (rather than a series of numbers as a reference)

@tristan-breon-1 URLs have some limitations. for example they can’t contain spaces, And if the title contains “?” some browser may interpret it as query parameters. and if there’s a slash in the title, it might be interpreted as a url path, and if there’s a # in the title it might get interpreted as a url particle.
Therefore before creating the urls you should encode the title.
It’ll be uglier but that’s the way it works.

@jonatandor35 Oh okay got it. But how can I do that? That either means I can’t use symbols such as & / () in the title OR, not include the title of the item in the URL… I wish there was a way to automatically remove the special symbols.

@tristan-breon-1 When you create a dynamic page, Wix automatically creates an encoded URL. Check your database, and you’ll find there a greyed cloumn with this url.
For example:
If you have a title:
[CDAV]-Jeu-Cyberpunk-2077—Edition-Day-One-sur-PS4-/F-Xbox-One-(/20€-crédités)

The url will be:
/product/%5Bcdav%5D-jeu-cyberpunk-2077—edition-day-one-sur-ps4-%2Ff-xbox-one-(%2F20%E2%82%AC-cr%C3%A9dit%C3%A9s)

@jonatandor35 Ok so oddly enough, it’s now working. I don’t know what changed inbetween. I hope it stays that way.

Thanks for the help!

@tristan-breon-1 maybe you tested it on a different browser?

Bump