Please, How To Direct Single Journal To Web Root (http://journalpage.com) instead of (http://journalpage.com?index.php/ojs)

Sorry, this is going to be technical. This tends to be one of the more complicated subjects in configuring OJS. The typical solution is to use Apache’s mod_rewrite ( mod_rewrite - Apache HTTP Server Version 2.2 ) in concert with OJS’s restful_urls ( https://pkp.sfu.ca/support/forum/viewtopic.php?f=2&t=2616&start=30 ) configuration.

There are gotchas in the HOWTO’s description depending on your Apache version: http://amandine.aupetit.info/135/apache2-mod_rewrite/

We really ought to have an updated HOWTO, but the number of possible configurations makes it a bit intimidating to maintain.

The core issue, from my perspective, is that for OJS 2.x you will need two URL hooks:

  • OJS “index” or site level access
    Normally this is the site root, but you are inverting the structure to hide this root.
    This will probably be a specific URI off of your root, perhaps http://journalpage.com/index
    It would need to live in your config.inc.php as base_url['index'] = http://journalpage.com/index
  • OJS journal level access
    This is your actually main landing page
    It needs to live in your config.inc.php as base_url['SHORTNAME'] = http://journalpage.com where SHORTNAME is the Journal’s short name.

Your re-write would look something like this:

RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/index/(.*)$ /index.php/index/$1 [L]

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php/SHORTNAME$1 [L]

(not actually tested)

3 Likes