?
avatar CBAlexHeinrich
CBAlexHeinrich
25 May 2014

In some LAMP setups following behaviour might occur:

During the process of building the URI, Joomla (2.5.17) builds a wrong URI.
What happens is, that Joomla tries, in "Apache Mode", to build the URI by
concentating ...


{Protocol}, $_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI].

But the Request-Uri in these setups contains the complete URI, namely ...


{Protocol}://{$_SERVER['HTTP_HOST']}/{$_SERVER['SCRIPT_NAME']}/{?$_SERVER['QUERY_STRING']

... so that the Joomla-built URI looks like this:


http://www.my-joomla-site.comhttp://www.my-joomla-site.com

Means to the User:

1) Installation gets stuck at "Step 1"
2) Calls to http://my-joomla-site.com result in a 404 error.

In order to correct this behaviour I changed the following piece(s) of code:

1) /libraries/joomla/application/web.php: (Ln 987)


$uri = $scheme . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

to ...


$uri = $scheme .
$_SERVER['HTTP_HOST'] .
str_replace(
$scheme .
$_SERVER['HTTP_HOST'],
'',
$_SERVER['REQUEST_URI']
);

2) /libraries/joomla/environment/uri.php: (Ln 173)


$theURI = 'http' . $https . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

to ...


$theURI = 'http' .
$https .
$_SERVER['HTTP_HOST'] .
str_replace(
'http' .
$https .
$_SERVER['HTTP_HOST'],
'',
$_SERVER['REQUEST_URI']
);

This also happens in Joomla 3.3.0, but the code is a little different.

Regards, Alex

avatar CBAlexHeinrich CBAlexHeinrich - open - 25 May 2014
avatar zero-24
zero-24 - comment - 25 May 2014

Hi @CBAlexHeinrich

can you please explain a bit more how we can reproduce the problem and test your patch?

For the code can you submit a github PR? With a PR we can e.g. easy tests, code review and merge your changes ;)

If you have a PR please link it here.

If you don't know how to do a PR please see here:
http://docs.joomla.org/Using_the_Github_UI_to_Make_Pull_Requests

PS: You can change multible files with one PR if you access your "patch branche" at
github.com/CBAlexHeinrich/joomla-cms/branches
or
github.com/CBAlexHeinrich/joomla-cms/tree/patch-(number)
e.g.
github.com/CBAlexHeinrich/joomla-cms/tree/patch-1

As we document our trackers atm outside of github please open a tracker at JoomlaCode:
http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemBrowse&tracker_id=8103

and link it back here.

Thanks @CBAlexHeinrich

avatar zero-24
zero-24 - comment - 25 May 2014

In some LAMP setups following behaviour might occur:

Which by example?

During the process of building the URI, Joomla (2.5.17) builds a wrong URI.

Please update your Joomla to 2.5.20 there are some bugfixes.

avatar CBAlexHeinrich
CBAlexHeinrich - comment - 25 May 2014

Hi zero-24,

I am running Debian on my laptop. In order to develop the sites i am working on, I installed Apache Webserver, PHP and the Mysql Server. Everything is running pretty much in "default" mode. In order to run more than one site, I use an automatic proxy configuration script, which points to either localhost, or goes directly to the internet, depending on the dns-domain/hostname.

LAMP SETUP

# uname -r
3.13-0.bpo.1-amd64
# apache2 -v
Server version: Apache/2.2.22 (Debian)
Server built:   Feb  1 2014 21:26:04
# mysql -V
mysql  Ver 14.14 Distrib 5.5.37, for debian-linux-gnu (x86_64) using readline 6.2
# php -v
PHP 5.4.4-14+deb7u9 (cli) (built: Apr 18 2014 14:34:31) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

proxy.pac

function FindProxyForURL(url, host) {

    var strReturn="";

    if (dnsDomainIs(host,"dev.example.local")) { 
        strReturn="PROXY 127.0.0.1:80";     
    } else strReturn="DIRECT";

    return strReturn;

}

To make Apache respond to my requests, I created some (basic) VirtualHosts, and enabled them via a2ensite.

<VirtualHost *:80>
        ServerAdmin ...
        ServerName {...}.dev.example.local
        DocumentRoot ...
        <Directory ...>
                Options -Indexes FollowSymLinks
                AllowOverride FileInfo
                  Order allow,deny
                allow from all
        </Directory>
</VirtualHost>

Regards, Alex

avatar zero-24
zero-24 - comment - 25 May 2014

But the Request-Uri in these setups contains the complete URI, namely ...

hmm but why? If we follow the PHP Docs the var $_SERVER['REQUEST_URI] is this:
"The URI which was given in order to access this page; for instance, '/index.html'."

See: http://www.php.net/manual/en/reserved.variables.server.php

avatar CBAlexHeinrich
CBAlexHeinrich - comment - 25 May 2014

Hi zero-24,

yes, I know. It might be a misconfiguration of my system. I just wanted to post this here, for those who experience the same behaviour and have a similiar setup. It took me hours to get joomla installed, up and running.

I will read and study some articles now. I'll come back to you.

Regards, Alex

avatar CBAlexHeinrich
CBAlexHeinrich - comment - 25 May 2014

Hi zero-24,

I found something out.

If you look at the HTTP-Request Headers you should be able to reproduce this behaviour.

Case 1)

GET http://{host}/{some_page} HTTP/1.1
Host: {host}
Connection: Close

In this case the Request-Uri on my system is

http://{host}/{some_page}

Case 2)

GET /{some_page} HTTP/1.1
Host: {host}
Connection: Close

In this case the Request-Uri on my system is

/{some_page}

And that is were the assumption is made, namely that only case 2 exits.

Regards, Alex

avatar zero-24 zero-24 - close - 25 May 2014
avatar CBAlexHeinrich
CBAlexHeinrich - comment - 25 May 2014

OK, i will mark this as closed. I think I got it now. This happens only when the transmitted URI is an absolute URI, containing protocol, hostname, path etc. This seemed to be the case on my system. Meaning, I "told" my browser use a proxy with the proxy.pac. But instead of having a real proxy installed, the request was directly sent to the Apache webserver. I read the RFC now, which states that in cases where the request is sent to a proxy, an absoulte URI is required. And thats what my browser did. The browser sent an absolute URI.

Regards, Alex

avatar CBAlexHeinrich CBAlexHeinrich - change - 25 May 2014
Status New Closed
Closed_Date 0000-00-00 00:00:00 2014-05-25 21:05:11
avatar CBAlexHeinrich CBAlexHeinrich - close - 25 May 2014
avatar zero-24 zero-24 - change - 7 Jul 2015
Labels Added: ?

Add a Comment

Login with GitHub to post a comment