Search code examples
urlmime-types

MIME media type (content type) for representing a URL?


I'm looking for the correct MIME media type (or content type) for documents that contain a single URL such as http://example.com/123/abc.

I checked IANA's MIME type registry, but couldn't find a suitable one for a URL or URI.

Should I create a custom MIME type for this purpose or use the closest registered that applies? It will be used by a RESTful API that returns a URL in the HTTP body for specific calls, to differentiate from others that do not.


Solution

  • You should be able to use text/uri-list defined in RFC 2483 Section 5. You are only returning a single URL, but there is nothing in the spec saying it can't be a list of one. To conform to the spec, just make sure the URL is all on one line and terminated with a CRLF pair.