better use of $mosConfig_live_site

Locked
User avatar
Elpie
Joomla! Guru
Joomla! Guru
Posts: 903
Joined: Wed Aug 17, 2005 11:26 pm
Contact:

better use of $mosConfig_live_site

Post by Elpie » Fri Dec 02, 2005 5:16 am

Currently $mosConfig_live_site gets picked up in the basic SEF as base href.

It's in includes\frontend.php and may be in other code as well.

if ( isset($mosConfig_sef) && $mosConfig_sef ) {
echo "\r\n";
}

The problem with this is that it forces sites into chosing to be either www or NO-www but not giving the option to be both.
Where Apache is set up for a domain with an alias to handle the url as either http://domain.com or http://www.domain.com, using $mosConfig_live_site is effectively hardcoding the url into being one or the other. 

Now, the www subdomain is deprecated (and the sooner everyone drops it the better!) but many visitors hold with the old ways and look for a domain under the www subdomain.  Until everyone stops doing this, sites have to make allowances for it.  But, a visitor should be able to navigate the entire site following the same path. 
If $mosConfig_live_site is set to domain.com and a visitor comes in through http://www.domain.com, dynamic links will throw them onto the NO-www path.  Ok, they are still on the site and seeing what they need.  Search engines, however, see this as moving from one site to another and will penalise sites for this.

I know that the argument is that everyone should just set $mosConfig_live_site to use www - but I have an issue with using something that is deprecated and unneccessary. 

A simple fix is to use $_SERVER['HTTP_HOST']

So, my request is this : could $mosConfig_live_site be changed/removed and $_SERVER['HTTP_HOST']  used instead?

I am not a coder, so I may be simplifying the change needed.  But after spending hours reading the Joomla code to find why my site is moving between www and NO-www, getting extra hits on Apache for its troubles, and getting penalised by Google for it, this is what I have pinpointed as being the problem.

Can this be fixed for the new release please?
For Mambo assistance: http://forum.mambo-foundation.org
Open Source Research & Best Practice: http://osprojects.info

User avatar
eyezberg
Joomla! Hero
Joomla! Hero
Posts: 2860
Joined: Thu Aug 25, 2005 5:48 pm
Location: Geneva mostly
Contact:

Re: better use of $mosConfig_live_site

Post by eyezberg » Fri Dec 02, 2005 7:42 am

Also, when I browse, I tend to simply enter the site name, and hit ctrl + enter (Win/IE) to get http://www. sitename .com automatically, so not using www is not an option as long as IE works like this (and NO, I'm not going to use FF as primary browser :) ).
Good suggestion (I think, also not being a coder really..) and: even better to see you around, Elpie!
Sometimes one pays most for the things one gets for nothing.
The important thing is not to stop questioning. Curiosity has its own reason for existing. AE
http://joomla15.[URL banned].com for J! 1.5 screenshots
http://www.eyezberg.com

User avatar
kper
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 198
Joined: Fri Aug 26, 2005 11:09 am

Re: better use of $mosConfig_live_site

Post by kper » Fri Dec 02, 2005 8:13 am

Yes, there definitely needs to be some solution to this, it is a bit of a pain.

Glad to see you back, Elpie.

User avatar
Elpie
Joomla! Guru
Joomla! Guru
Posts: 903
Joined: Wed Aug 17, 2005 11:26 pm
Contact:

Re: better use of $mosConfig_live_site

Post by Elpie » Fri Dec 02, 2005 10:03 am

Thanks guys - I am not exactly back ;)

I just spent so long searching thru code after having a sys admin spend ages trying to find whether my server set-up was causing the problems, that having found it I thought it churlish not to alert the devs to the issue. 
Figured that if it was a problem to me it may well be a problem for others too ;)

Logic tells me that putting this into config should fix that problem, but I am not a coder and dont have a clue whether anything else would be adversely affected (and not about to try it on a live site - call me chicken!):

$mosConfig_live_site = $_SERVER['HTTP_HOST'];

Would it break anything?  Anyone game to try it out?  If it does work then it makes sense to set it in concrete in configuration.php except that it may then restrict local development on some systems.
Last edited by Elpie on Fri Dec 02, 2005 10:05 am, edited 1 time in total.
For Mambo assistance: http://forum.mambo-foundation.org
Open Source Research & Best Practice: http://osprojects.info

User avatar
Elpie
Joomla! Guru
Joomla! Guru
Posts: 903
Joined: Wed Aug 17, 2005 11:26 pm
Contact:

Re: better use of $mosConfig_live_site

Post by Elpie » Fri Dec 02, 2005 11:50 am

Update:
Took the plunge and tried changing the live_site in configuration.php to this:

$mosConfig_live_site = $_SERVER['HTTP_HOST'];

I can now report that the live site I tried it on ended up with no template, css or images :D

It's a brilliant way to test how accessible the site is  ;)  Don't recommend others try it tho'.
For Mambo assistance: http://forum.mambo-foundation.org
Open Source Research & Best Practice: http://osprojects.info

User avatar
eyezberg
Joomla! Hero
Joomla! Hero
Posts: 2860
Joined: Thu Aug 25, 2005 5:48 pm
Location: Geneva mostly
Contact:

Re: better use of $mosConfig_live_site

Post by eyezberg » Fri Dec 02, 2005 3:32 pm

@ avatar: I thought Felix was a cat, not a kitten..? ;) Mine's smilyng at least.. :D
Thanks for trying, I guess one of the devs will find a suitable alternative.
Sometimes one pays most for the things one gets for nothing.
The important thing is not to stop questioning. Curiosity has its own reason for existing. AE
http://joomla15.[URL banned].com for J! 1.5 screenshots
http://www.eyezberg.com

User avatar
Vimes
Joomla! Ace
Joomla! Ace
Posts: 1682
Joined: Fri Aug 19, 2005 12:14 am
Location: United Kingdom
Contact:

Re: better use of $mosConfig_live_site

Post by Vimes » Fri Dec 02, 2005 7:04 pm

Elpie wrote: Thanks guys - I am not exactly back ;)
A little bit is better than nothing.
http://www.jomres.net THE online hotel booking and reservation system for Joomla and Wordpress.

User avatar
brad
Joomla! Master
Joomla! Master
Posts: 13419
Joined: Fri Aug 12, 2005 12:38 am
Location: Sydney - Australia
Contact:

Re: better use of $mosConfig_live_site

Post by brad » Fri Dec 02, 2005 7:33 pm

Have you tried: http://".$_SERVER['SERVER_NAME'] ?
Brad Baker
https://xyzulu.hosting
https://www.joomlatutorials.com <-- Joomla Help & Tutorials

User avatar
Elpie
Joomla! Guru
Joomla! Guru
Posts: 903
Joined: Wed Aug 17, 2005 11:26 pm
Contact:

Re: better use of $mosConfig_live_site

Post by Elpie » Tue Dec 13, 2005 11:40 am

I have tested the following out in a couple of sites and it works. 

Code: Select all

$mosConfig_live_site = 'http://'. $_SERVER['HTTP_HOST']; 
I intend to make this change in every Mambo and Joomla site I control.  It returns the correct base href and keeps visitors on the url on which they enter, so www stays www and NO-www stays without it.

I feel that this is a much better way to handle $mosConfig_live_site because, apart from anything else, it respects the way the server has been set up and allows the aliasing to work. 

I would like to see this become the default, "out of the box" setting however while I know it works like a charm on Linux/UNIX based servers, I don't know what the implications are for Windows servers. 
For Mambo assistance: http://forum.mambo-foundation.org
Open Source Research & Best Practice: http://osprojects.info

User avatar
louis.landry
Joomla! Ace
Joomla! Ace
Posts: 1388
Joined: Wed Aug 17, 2005 11:03 pm
Location: San Jose, California
Contact:

Re: better use of $mosConfig_live_site

Post by louis.landry » Tue Dec 13, 2005 11:54 am

Good idea...

Louis
Joomla Platform Maintainer
A hacker does for love what others would not do for money.

User avatar
Hackwar
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3763
Joined: Fri Sep 16, 2005 8:41 pm
Location: NRW - Germany
Contact:

Re: better use of $mosConfig_live_site

Post by Hackwar » Tue Dec 13, 2005 8:56 pm

Elpie wrote:

Code: Select all

$mosConfig_live_site = 'http://'. $_SERVER['HTTP_HOST']; 
Setting http as static would (in my opinion) prevent https to be used. Or do I miss something? You would have to see which protocol has been called.

Hackwar
god doesn't play dice with the universe. not after that drunken night with the devil where he lost classical mechanics in a game of craps.

Since the creation of the Internet, the Earth's rotation has been fueled, primarily, by the collective spinning of English teachers in their graves.

User avatar
Elpie
Joomla! Guru
Joomla! Guru
Posts: 903
Joined: Wed Aug 17, 2005 11:26 pm
Contact:

Re: better use of $mosConfig_live_site

Post by Elpie » Tue Dec 13, 2005 11:22 pm

I'm not sure where/how https is called in the script if users dont want their entire site to run under SSL, as http is there in $mosConfig_live_site anyway, regardless of whether $mosConfig_live_site = 'http://'. $_SERVER['HTTP_HOST'];  is used or $mosConfig_live_site = 'http://yourdomain'; (the usual way its entered) .

There are a number of hacks that have been discussed about how to enable SSL on the backend without having to make an entire site run under https (which is the case if $mosConfig_live_site = 'https://yourdomain'; ). I understand that this is being addressed in 1.1.

The only difference my change makes is that it takes the domain name from the server instead of harcoding it into the config.  Most servers these days are set up to allow aliasing from domainname.com to http://www.domainname.com, which enables visitors to come in through either the www of NO-www path.  Using HTTP_HOST allows that to continue and when SEF is enabled it dynamically sets base href as either www or NO-www, depending on how the visitor has come onto the site. 

Nobody ever knows how a visitor is going to access a site. For sites that don't use www, they will still have people who come in trying to use it and many who link to the site will create links using www in the url.  Until everyone wakes up to the fact that www is deprecated and unneccessary anyway, allowances have to be made for this. 

Rey said back in September that SSL handling would be in 1.1:
it is a setting that will be configirable via the admin panel and set for individual menu items if necessary.
so I hope this is still the plan for 1.1 ;)
Last edited by Elpie on Tue Dec 13, 2005 11:25 pm, edited 1 time in total.
For Mambo assistance: http://forum.mambo-foundation.org
Open Source Research & Best Practice: http://osprojects.info

User avatar
louis.landry
Joomla! Ace
Joomla! Ace
Posts: 1388
Joined: Wed Aug 17, 2005 11:03 pm
Location: San Jose, California
Contact:

Re: better use of $mosConfig_live_site

Post by louis.landry » Tue Dec 13, 2005 11:29 pm

Not so much "in the plan" as it is "in the source tree" :)

Your suggestion on the $_SERVER['HTTP_HOST'] is a good one.... looking into how to combine this with the current SSL switching mechanism

Louis
Joomla Platform Maintainer
A hacker does for love what others would not do for money.

User avatar
Elpie
Joomla! Guru
Joomla! Guru
Posts: 903
Joined: Wed Aug 17, 2005 11:26 pm
Contact:

Re: better use of $mosConfig_live_site

Post by Elpie » Tue Dec 13, 2005 11:36 pm

That is really good news Louis :)
Thanks
For Mambo assistance: http://forum.mambo-foundation.org
Open Source Research & Best Practice: http://osprojects.info

User avatar
Moutro
Joomla! Explorer
Joomla! Explorer
Posts: 415
Joined: Wed Jan 04, 2006 10:08 pm
Contact:

Re: better use of $mosConfig_live_site

Post by Moutro » Wed Jan 18, 2006 1:58 pm

Just to be sure
are you saying that change be aplyed to the configuration.php file ? only
If so it seems i just tested it on
an apache 2 running on windows xp and seems to run fine.
Just SEF creating seems seems a little slow about 1 sec behind
Will run a stress test lata from difrent machines and see
| Become a Certified L.S.P  User Today | LINK the sites concerning the issues | SEARCH the forums first to find the answers | POST your questions with clear titles |

idesigns
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Tue Dec 04, 2007 3:39 pm

Re: better use of $mosConfig_live_site

Post by idesigns » Tue Dec 04, 2007 3:46 pm

Hey guys just got on here. I am having problems with this.

I changed my config file to $mosConfig_live_site = 'http://'. $_SERVER['HTTP_HOST'];

However when you save your configuration in the CMS it changes this back to the way it was. I was thinking we need to change something in "/administrator/components/com_config/admin.config.php    so the hacks would stay saved in the configuration.php file.


Locked

Return to “Wishlist Archives - Archived”