HowTo: add media files to content with relative links

Topics: Troubleshooting
Sep 28, 2011 at 2:25 PM

We have installed Orchard on a server on premises and have been customizing it there. Our on premises ("test server") server is a Windows 2008 Server, where we created a new virtual directory/application under wwwroot, like c:\inetpub\wwwroot\myOrchardWebsite (top URL: http://mylocalserver/myOrchardWebsite ), but when we copy it to Cytanium shared hosting ("production server"), all files are copied to the wwwroot folder, like ..\inetpub\wwwroot (top URL: http://www.moving2u.pt )

Once in a while we may need to copy the website from one side to the other, so we don't want any of the media related links to be absolute, so that the same files & database (except the database connection string) work on both production server and test server.

We have customized many URLs for CSS dependencies to have relative folders, so they ignore the top domain and IIS subfolder, but for images added to media, when we had them to content, their links are hardcoded to the full absolute URL. I realize than in the database, on the xxx_Common_BodyPartRecord table I can fix the URLs to make them relative links, but would like to have some guidance on how sholud this be handled so there are no crossed links between both servers.

Thanks,

Alberto Silva

 

Coordinator
Sep 28, 2011 at 6:00 PM

I can't reproduce that. When I add media using the media picker, it has a relative url.

Coordinator
Sep 28, 2011 at 7:26 PM

Well, is has the ApplicationPath in it I think ... isn't it ? Same problem then.

Coordinator
Sep 28, 2011 at 7:41 PM

No it's not the same problem because then you have a workaround, which is to have the same application path on your dev machine. Still sucks but workable. If it's really absolute, server-rooted paths, you're screwed. fortunately it doesn't seem to be the case.

Sep 28, 2011 at 8:03 PM

Hi,

I'm pretty sure I haven't changed anything on configurations, just fixed some theme issues, but now it no longers includes the top domain, only the path after the domain, even on the database. However, it does still include the IIS application directory name, I'll check later what happens when I copy this to the shared hosting.

Thanks for the replies,

Alberto Silva