What is the clean way to use "/" in the part of the url

In the MVC structure, I have a model with an identifier field. This field can be any that is used by the user as a unique identifier. Then I use this identifier field in the URLs to access the corresponding resources.

/people/<identifier>/ 

In one such case, the user uses 00/000 format identifiers. A problem will be quickly identified among you - how do we know which part is the identifier and which part of the action?

The obvious solution is to use URL escaping (% 2F is the appropriate code). However, this confuses my apache load balancer proxy, as well as the application server in our demo field (the passenger is working). Although this is annoying, it works fine on local development servers. URLs, including% 2F, seem to be causing 404 errors from the server (not the application!).

What I'm looking for is a general approach to solving this problem, while maintaining a neat URL.

The stack that caused this problem is Ruby 1.8.7, Merb 1.0.12, Apache load balancing for a thin cluster during production, Passenger on a demo server, and working with an ill-conceived thin during development.

+4
source share
2 answers

You can always use the internal encoding, which replaces / with some other character that is never used in your identification field, and then converts it back when reading it from the URL.

For instance:

http: // yoursite / people / 00/000

becomes

http: // yoursite / people / 00-000

+1
source

The cleanest way is to prevent the user from entering the first slash character. If it is necessary to support this format, then there is no way to use URL escaping.

+4
source

All Articles