Base URL

5 posts by 3 authors in: Forums > CMS Builder
Last Post: March 18, 2013   (RSS)

By Toledoh - March 13, 2013

Hi Guys,

My understanding is that I should be developing sites with Site Relative URL's, however my host set's up staging servers as something like 111.111.111.111/~sitename/ so all my links are out.

By my reading of things, I should be able to use something like <base href="http://111.111.111.111/~sitename/"> in the <head> tag - but this doesn't seem to work.

Is there a good way of working with this kind of thing?

Cheers,

Tim (toledoh.com.au)

By Toledoh - March 13, 2013

save people time and hassle we'd like to do that

That's why I love you guys:)  Thanks!

Cheers,

Tim (toledoh.com.au)

Hi Dave,

That suggested tweak to deal with the pre-domain sites with URL like: http://111.111.111.111/~account/... would be very welcome indeed!

J

By Dave - March 18, 2013

Hi Tim & Jayme, 

I've got a beta on that feature for 2.53.  I'll send you a zip so you can try it.  It's a new field called "Website Prefix URL" in the admin.  You can set it and it adds it to everything, and remove it and it's gone. So this supports urls like /~username/file.php and also developers who have a directory structure like this:
http://www.webdesignco.example/clients/megacorp-abc/index.php

Viewer links are automatically updated and we also make a global available like this: <?php echo PREFIX_URL ?>

So you can have a tag like this: <img src="<?php echo PREFIX_URL ?>/images/myimage.jpg" /> and it will work on any development or live server url: 
http://www.webdesignco.example/clients/megacorp-abc/images/myimage.jpg
http://www.webdesignco.example/~megaco/images/myimage.jpg
http://www.megacorp-123.com/images/myimage.jpg

Hope that makes sense.  It will once you try it.  

Let me know any questions.

Dave Edis - Senior Developer
interactivetools.com