We serve every country under a two-letter path: /es is Spain, /id is Indonesia, /ng is Nigeria. The slug is just strtolower($countryCode). Simple, readable, and it worked for 85 countries.

Then we added Malaysia. Its ISO 3166 code is MY.

The collision nobody saw coming

/my was already taken. Long before Malaysia, it was the URL space for one of our products: the driver's own area, with hundreds of routes under it, all named my.* in Laravel.

Seeding Malaysia as my produced duplicate route names (my.landing, my.login, my.my), each registered twice. Laravel does not throw on a duplicate route name; the one registered last simply wins. So route('my.login') silently became a coin toss depending on registration order, and a driver's dashboard URL started serving the Malaysian country hub instead. It was live for about twenty minutes before we caught it.

It could never have worked anyway: our country resolver had always excluded my as "two letters but not a country", because that path was reserved from day one. So Malaysia fell back to the UK, and the Malaysian hub rendered Malay text with a British country underneath it.

Why not just pick another two letters?

Because every other two-letter string is some real country's ISO code. ml is Mali, mm is Myanmar. Borrowing one just buries the next landmine for whoever adds that country later.

So Malaysia got a word instead: /malaysia. It is also what people actually type into search, so the URL earns its keep.

The rule that came out of it

Once one country is an exception, a slug is no longer a country code, and the two strings must never be confused again:

countrySlug('MY'); // 'malaysia' → use it to BUILD LINKS countryCode('malaysia'); // 'MY' → use it to LOOK UP A COUNTRY 

The override lives in one tiny config file, country-slugs.php, with a single line: 'MY' => 'malaysia'. Everything that builds a URL goes through countrySlug(); everything that looks up currency, tax or language goes through the ISO code.

The bug this prevents is the lazy one: strtoupper($slug) to get a country code. It works for 85 countries and breaks the 86th. We had already met its cousin once, when a language slug (/es) was read as a country and an Ecuadorian user was registered as a Spanish company.

Three things worth stealing

  1. A route name is a namespace too. We checked URIs for collisions and still got burned by route names. A name like my can occupy the URI, the route name, a lang file, a table and a CSS class at once.
  2. Duplicate route names fail silently in Laravel. Add a test that registers your routes and asserts names are unique.
  3. Separate "what goes in the URL" from "what identifies the thing" the moment one exception appears, not after the second.

If you want to see the result, the Malaysian pages now live at mekavo.com/malaysia. Every other country still has its two letters.