Page 1 of 1

Force all urls to be relative

Posted: Fri Oct 27, 2006 1:37 am
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

Re: Force all urls to be relative

Posted: Fri Oct 27, 2006 1:50 am
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.

Re: Force all urls to be relative

Posted: Fri Oct 27, 2006 3:50 pm
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

Re: Force all urls to be relative

Posted: Fri Oct 27, 2006 10:22 pm
by Dr.CSS
Have you got the in the header? from the {metadata} tag...

Re: Force all urls to be relative

Posted: Sun Oct 29, 2006 5:31 am
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!