SpaceJump
SpaceJump

Reputation: 483

Sitecore - Leading slashes in image URLs after Update

We have a Sitecore 6.6 updated from 6.3.

On 6.3 when an image was linked from the media library in the rich text editor, the src generated link looked like this:

src="/~/media/499880737CD24BF7A640E0DB2652C909.ashx?w=646&h=830&as=1"

Which worked fine.

Now after the update to 6.6 a leading slash is added to the src:

src="//~/media/499880737CD24BF7A640E0DB2652C909.ashx?w=646&h=830&as=1"

The image is visible in the rich text editor in the backend, but not on the website.

So where does this leading slash come from? I googled and tried many possible solutions, but nothing worked so far. I also checked this thread (Sitecore 6.5 rev. 120247 media urls adding a leading slash), but my "Media.MediaLinkPrefix" is already empty.

EDIT:

I just checked our 6.3 backup and the image src actually looks like this:

src="//hostname/~/media/499880737CD24BF7A640E0DB2652C909.ashx?w=646&h=830&as=1"

Could the missing hostname be the problem? If I add manually add it and put it into the browser, it works.

Upvotes: 2

Views: 824

Answers (2)

Martin Miles
Martin Miles

Reputation: 2096

To fix that, check the following settings involved in src generation and processing:

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

If it starts with slash - remove it. Also check that setting, that assigns a prefix to media links:

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

Finally, there can be any URL Rewrite feature (or reverse proxy) enabled that rewrites URL on the fly, however that is very unlikely.

Upvotes: 0

Ian Graham
Ian Graham

Reputation: 3216

I think this might be due to a change in the way media items urls are rendered in Sitecore 6.4+.

According to Sitecore John, in versions 6.4 and above, a slash is prepended to the media url to solve some issues with SEO and IIS. If you already have code such as this:

 mediaPath = Sitecore.StringUtil.EnsurePrefix('/',MediaManager.GetMediaUrl(mediaItem))

You will now have two slashes rather than just one.

More info on this here:

http://www.sitecore.net/learn/blogs/technical-blogs/john-west-sitecore-blog/posts/2012/12/sitecore-idiosyncrasies-media-urls.aspx

Upvotes: 3

Related Questions