Keep in mind that REST doesn't care about what spelling conventions you use for your identifiers. Either two URI are the same, in which case the client will assume they refer to the same resource, or the two URI are different, in which case the client will assume they refer to different resources.
/users/{id}
/users/{code}
In this case, it sounds like your problem is trying to distinguish which resource is intended when the integer you get is ambiguous.
Since the integer is ambiguous, you need to make the distinction in the URI elsewhere. REST doesn't particularly care how you do that, so long as the identifiers are consistent with RFC 3986.
/ebc8a29b-76a5-4f40-b37a-2d40eab9283d/{id}
/9193590d-fc47-4107-a160-e344b9cedb5c/{code}
Is a perfectly satisfactory solution as far as REST is concerned.
/usersById/{id}
/usersByCode/{code}
That's also perfectly satisfactory, and is perhaps more easily consumed by humans.
/users/id={id}
/users/code={code}
Another satisfactory example; which gives you readability and the shared /users
path segment, which may be convenient if you want relative references embedded in a representation.
Matrix parameters is a commonly used term that covers a number of different ways of embedding information within a path segment; there's a reasonable hope that, if you are using a standard/3rd-party library for parsing your URI, that some or all of those conventions will be supported.