We are using DD4T on SDL Tridion 2011 SP1 HR1. When presenting images from within a RTF we note that the root path is added twice to the image path/filename.
We have configured the web app under a virtual path /vpath/ as read from the webserver variables HttpContext.Current.Request.ApplicationPath
.
Images are being presented to the deployed environment as /vpath/vpath/images/image-name.jpg
- any ideas if we're missing a configuration to indicate the path prefix is not required?
We originally setup the publication with the /vpath part in the URL in the Publications Settings Path and later the requirement (IT team) was to setup the application to run under a virtual directory.
We'd initially thought we could reuse a web.config setting we have to indicate that the application runs under a virtual directory (for other functional requirements)
<add key="VirtualDir" value="vpath" />
and just update the method to:
public static string AdjustUrlToContext(string url)
{
if (!string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["VirtualDir"])
return url;
return HttpContext.Current.Request.ApplicationPath + url;
}
But we also need to consider if we create another publication and the publication setting does not include the virtual path.
Update:
Indeed, the proper solution would be to not have the virtual path in the publication path but given we are stuck where we are right now and need a fix before re-visiting,
we could check if the URL passed in already starts with the VirtualDir
and then remove it... I don't like the idea of just removing full stop... I know we can 'manage' this going forward by not having the prefix in the publication settings but it assumes too much.
So let's imagine we do have a /anothersite/anothersite/index.aspx
... the above code is saying this is simply not allowed as a consequence of a legacy issue. Bad times.