2

I have a website developed in C# with Sitecore, and I have this URL:

http://dev.take.com.web.unity.internal.com/~/media/group/images/media/content/19590.ashx?h=180&mh=219&mw=514&w=5120

For some images, I don't understand this URL and what the (~) symbol means.

Derek Hunziker
  • 12,996
  • 4
  • 57
  • 105
davdomin
  • 1,219
  • 6
  • 18
  • 38

2 Answers2

7

In Sitecore, ~/media/ is a URL prefix that triggers the media handler, which in turn tells Sitecore that the request is for a media library item. These requests are handled differently then a request for a item under the site root.

The prefix is defined in the sitecore/customHandlers section of the web.config:

<customHandlers>
   <handler trigger="~/media/" handler="sitecore_media.ashx" />
</customHandlers>

If you decide to change this value, you will also need to also update the following setting so that new links get generated with the new prefix:

<setting name="Media.MediaLinkPrefix" value="" />

That said, if you have preexisting links to media items that were created in the Rich Text editor, it might be smarter to add an additional prefix so that the default ~/media/ prefix remains valid. To configure additional prefixes, add them to the <mediaPrefixes> section of the web.config as shown below:

<!-- MEDIA REQUEST PREFIXES
     Allows you to configure additional media prefixes (in addition to the prefix defined by the Media.MediaLinkPrefix setting)
     The prefixes are used by Sitecore to recognize media URLs.
     Notice: For each custom media prefix, you must also add a corresponding entry to the <customHandlers> section
-->
<mediaPrefixes>
  <!-- Example
  <prefix value="-/media"/>
  -->
</mediaPrefixes>
Derek Hunziker
  • 12,996
  • 4
  • 57
  • 105
1

Specification of the URI: RFC 3986

reserved = gen-delims / sub-delims  
gen-delims  = ":" / "/" / "?" / "#" / "[" / "]" / "@"  
sub-delims  = "!" / "$" / "&" / "'" / "(" / ")"  
                  / "*" / "+" / "," / ";" / "="

It's not withing the list of reserved characters, meaning it does nothing special. Usually it's an indication of a directory though.

2.3. Unreserved Characters

Characters that are allowed in a URI but do not have a reserved purpose are called unreserved. These include uppercase and lowercase letters, decimal digits, hyphen, period, underscore, and tilde.

unreserved  = ALPHA / DIGIT / "-" / "." / "_" / "~"
Community
  • 1
  • 1
Jeroen Vannevel
  • 43,651
  • 22
  • 107
  • 170