Skip to content Skip to navigation

OJS Virtual Host Proxy Configuration

Posted by: 


Configuring Open Journal Systems (OJS) to work with Stanford's Virtual Host Proxy (aka, "vanity URL") service requires some configuration tweaks to get all paths working properly. When installing a new instance of OJS (or adding a new journal to an existing installation, with its own virtual host proxy), you'll need to make changes to the following files to get it working:

  • index.php
  • classes/core/

The instructions below assume that you have a working OJS installation, and want your vanity URL to point to your journal. Let's assume you have OJS installed in the cgi-bin directory of your AFS group called publicknowledge. Let's also say that your journal is called Ephemera, and you want to point to your journal.

Step 1: Request a Virtual Host Proxy

Go to to request a virtual host proxy for your journal from ITS.

Enter the following information on the form:

  • Virtual Host Name: ephemera
  • Website Address:
  • Virtual Host Type: Proxy
  • Additional Configuration: Please configure this proxy to use SSL, i.e.,
Screenshot of virtual host proxy request form

Configuration options for requesting the virtual host proxy.

Step 2: Modify index.php

Add the following lines to index.php, right after the opening <?php tag:

// mrmarco: take care of PHP < 5.24 bug when run under CGI

The first few lines of your index.php should therefore look like this:

// mrmarco: take care of PHP < 5.24 bug when run under CGI
 * @mainpage OJS API Reference

Step 3: Modify

Comment out disable_path_info

Find the line that reads:

disable_path_info = On
and comment it out so that it reads:
; disable_path_info = On

Add an index base_url and a base_url for your journal

Add the following lines to the base_url section:

base_url[index] =
base_url[ephemera] =

Step 4: Modify

In classes/core/, modify the getServerHost function (starting at line 189) to the following:

	 * Get the server hostname in the request.
	 * @return string
	function getServerHost($default = 'localhost') {
		static $serverHost;
		if (!isset($serverHost)) {
			$serverHost = 
            // mrmarco: removed test for HTTP_X_FORWARDED_HOST
		    // :
                (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST']
				: (isset($_SERVER['HOSTNAME']) ? $_SERVER['HOSTNAME']
				: $default));
			HookRegistry::call('Request::getServerHost', array(&$serverHost));
		return $serverHost;