OAI baseURL does not corresponding with URL

Hi everybody,

I found the solution. The problem is when your OJS instance is behind an APACHE server. When if it is your case then you should change the PKPRequest.inc.php file as next:

 function getBaseUrl($allowProtocolRelative = **true**) 
{

                $_this =& PKPRequest::_checkThis();
                $serverHost = $_this->getServerHost(false);

                if ($serverHost !== false) {
                        // Auto-detection worked.
                        if ($allowProtocolRelative) {
                                $baseUrl = '//' . $_this->getServerHost() . $_this->getBasePath();
                        } else {
                                $baseUrl = $_this->getProtocol() . '://' . $_this->getServerHost() . $_this->getBasePath();
                        }
                } else {
                        // Auto-detection didn't work (e.g. this is a command-line call); use configuration param
                        $baseUrl = Config::getVar('general', 'base_url');
                }
                HookRegistry::call('Request::getBaseUrl', array(&$baseUrl));
                return $baseUrl;
        }

The problem is because allowProtocolRelative is now true, and $baseUrl = '//' . $_this->getServerHost() . $_this->getBasePath();

The solution is simple, just add “https:” to $baseUrl inside IF conditional, like this:

$baseUrl = ‘https://’ . $_this->getServerHost() . $_this->getBasePath();

Now, my OJS system can generates URL correctly.

3 Likes