Force all urls to be relative

Help with getting the CMS CORE package up and running. This does not include 3rd party modules, PHP scripts, anything downloaded via module manager or from any external source.
Locked
mattandaniel

Force all urls to be relative

Post by mattandaniel »

Hi there,

I'm making a site for both Australia and New Zealand. For users browsing to www.site.com.au I want the .com.au to persist throughout their whole time at the site, and for users browsing to www.site.co.nz I want the .co.nz to persist. The only way I can think to do this is to leave the document root blank. That is, in config.php:

$config['root_url'] = '';

This removes the full site url from all links. I haven't seen any problems with doing with so far, and I can't think of any real advantage of having the full url there (unless, perhaps for SEO reasons).

Can anyone enlighten me as to whether what I've done will cause problems at some point or if it is a good/bad idea?

Thanks
mattandaniel

Re: Force all urls to be relative

Post by mattandaniel »

... Just figured out what the problem with this method is.

Well, it works fine under firefox, but IE6 has a problem with relative urls that start with a '/' - it interprets them as 'http:///'

For example, when I click on the link to '/index.php?page=contact-us' IE6 tries to browse to 'http:///index.php?page=contact-us'.

Can someone offer another approach? I've done a bit of research into mod_rewrite though it doesn't seem to be possible to rewrite the domain name itself.
Pierre M.

Re: Force all urls to be relative

Post by Pierre M. »

One content, two domains, one hosting computer, right ?

I don't know if it works, but try this :
-install CMSms for one domain, as usual, in the domain1 zone of the webserver.
-install again in the domain2 zone of the webserver, not creating tables, just pointing to the existing ones.

The two installs are identical except config.php ($config['root_url']...).

Try at your own risk.

PM
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Force all urls to be relative

Post by Dr.CSS »

Have you got the in the header? from the {metadata} tag...
mattandaniel

Re: Force all urls to be relative

Post by mattandaniel »

Thanks for your suggestions, guys!

So that's what the base tag is for :-).

My CMSMS home page contains a user defined tag that redirects to the appropriate home page. I have a different template for AU and NZ, each with a custom metadata global content block with the appropriate base tag set.

I had to make my own metadata GCB's because CMSMS always puts a base tag in by default. If you leave 'root_url' = '' in config.php, it will put in , and there's no way through the CMSMS interface to turn it off. If you put abother base tag after it in your template to override it, it works fine in all browsers but IE7. So custom metadata GCB (or user defined tags, I suppose) are the only option.

Thanks again for your help!
Locked

Return to “[locked] Installation, Setup and Upgrade”