diff --git a/index.php b/index.php index ec0c4e7..3eaa45c 100644 --- a/index.php +++ b/index.php @@ -39,10 +39,17 @@ reset($records); ksort($timestamps); reset($timestamps); +// Get current base URL +if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') { + $baseURL = 'https://'.$_SERVER['HTTP_HOST'].parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); +} else { + $baseURL = 'http://'.$_SERVER['HTTP_HOST'].parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); +} + // Build the Identify response $identifyResponse = array( 'repositoryName' => $config['repositoryName'], - 'baseURL' => $config['baseURL'], + 'baseURL' => $baseURL, 'protocolVersion' => '2.0', 'adminEmail' => $config['adminEmail'], 'earliestDatestamp' => gmdate('Y-m-d\TH:i:s\Z', key($timestamps)), @@ -51,7 +58,7 @@ $identifyResponse = array( ); $oai2 = new OAI2Server( - 'http://'.$_SERVER['HTTP_HOST'].parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH), + $baseURL, $_GET, $identifyResponse, array( diff --git a/oai2config.php b/oai2config.php index b89d819..edaad70 100644 --- a/oai2config.php +++ b/oai2config.php @@ -29,9 +29,6 @@ $config = array(); // A human readable name for the repository $config['repositoryName'] = 'Simple OAI 2.0 Data Provider'; -// The base URL of the repository, i.e. the directory you deployed the files to -$config['baseURL'] = 'http://www.example.org/oai2/'; - // Email address for contacting the repository owner $config['adminEmail'] = 'admin@example.org';