@ctgraham
OJS is installed in /var/www/html/ojs. All document roots of the vhosts point to /var/www/html.
I meanwhile tried swichting the configuration. In the OJS config.inc.php i disabled all base_url override settings and set restful urls to “off”. In the apache vhosts conf files for test1.domain and test2.domain i modified the directory path (but not the document root) by adding the ojs subdirectory and i moved the rewrite rules in the directory section:
With this setting accessing test1.domain/ojs leads to the OJs overview page but from there you can easily get to the test1 journal which is linked with test1.domain/ojs/index.php/test1. Then the layout seems to be fine and you can access the journal backend without problems. But it is also possible to access the test2 journal with test1.domain/ojs/index.php/test2.
If OJS is installed in a subdirectory, you will generally want your base_urls and rewrites to assume that subdirectory is part of the OJS path. E.g.:
DocumentRoot /var/www/html
base_url[test1] = http://test1.domain/ojs
By accessing http://test1.domain directly, you want your document root to be the OJS directory, and you want your base_urls and rewrite to omit the subdirectory:
I had to enable the two “REQUEST_FILENAME” rewrite conditions else there is an not found error (“The requested URL /ojs/index.php/test1/ was not found on this server.”). After enabling these two conditions und disabling the other rule pair you get a response. Accessing http://test1.domain shows the OJS overview page with the two available journals and their current issue links. The page has no styles applied and looks blank. The journal links redirect to http://test1.domain again, so you are stuck with the overview page. The current issue links redirect to http://test1.domain/issue/current which is not found on the server (“The requested URL /ojs/index.php/test1/issue/current was not found on this server.”).
What version of Apache are you running? The %{REQUEST_FILENAME} variable is typically only effective for Apache before version 2.2.
The restful_urls option determines whether or not OJS will output URLs including (off) or excluding (on) the “index.php” file as part of the path.
Your directives for test1.domain consistently reference the target of your RewriteRules as pointing to the index.php file as living under an “ojs” subdirectory, but your Directory and DocumentRoot directives and base_url[test1] option strongly imply that OJS is installed directly in DocumentRoot, not in an “ojs” directory under DocumentRoot.
The structure of a RewriteRule is: RewriteRule [inputPath] [pathToMapTo]
So, for example: RewriteRule ^/(index.php)?/?$ /ojs/index.php/test1/index
means
Rewrite any request for /, or /index.php, or /index.php/ to the URL /ojs/index.php/test1/index.
That URL won’t exist. I would expect it to look more like: RewriteRule ^/(index.php)?/?$ /index.php/test1/index
Accessing test1.domain shows the test1 starting page. All the style files seem to have been applied. You can access articles and also the journal backend. The only noticeable effect is that some symbols like the magnifying glass in the search bar oder the PDF-symbols in the fulltextbuttons seem to be broken:
And on the ojs journal index page which lists all available journals the css-style style is not applied so it looks blank. I checked in the site source code and the link to the css results in an 404-error
Accessing the test2 journal on the main page via http://journals.uni-giessen.de/test2 has no flaws so far. The index.php is removed from the address, all styles are found and also the icons that are broken on the test1-journal work here.
With “restful_urls” on, all URLs will be output without the index.php component for the site. Because of that, you’ll need an additional mod_rewrite rule to rewrite URLs of the form “^/index/(.*)” to /index.php/index/$1.
See this thread for cross-origin considerations in displaying the glyphicons:
At first it didn’t work. But after creating an empty folder on the filesystem level /var/www/html/ojs/index everything is fine. And the glyphicons also have recovered (magically).
It seems you are finally successful to set each journal with its own domain name.
I read the long story, but still don’t find a way to follow your method. Could you summary your method in a documentation? I think it will help a lot of people like me.
Thank you in advance
@Buyi_Li
Here is my mini HOWTO for configuring different domain names in a single OJS installation. They have been tested on Ubuntu 16.0.4 and a recent Open Suse, both running Apache 2.4.
Goal: You have a main journal platform (journals.uni-giessen.de) with some journals. The index.php in the URL should be stripped from all journals. Some of your journals are fine with staying on your main journal page. Others want to have their own domain (rmm-journal.de).
OJS is installed in /var/www/html/ojs
Activate the apache rewrite mod
Set up you apache hosts
For the main journal platform:
<VirtualHost *:80>
<Directory /var/www/html/ojs>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ServerName journals.uni-giessen.de
DocumentRoot /var/www/html/ojs
</VirtualHost>
For the journal that wants its own domain:
<VirtualHost *:80>
<Directory /var/www/html/ojs>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ServerName rmm-journal.de
DocumentRoot /var/www/html/ojs
</VirtualHost>
The options in in directory clause are important. You also have to consider the servernames with www and port 443 configuration. For better overview i stripped this from the example
Create an empty directory “index” in the ojs directory on the filesystem level /var/www/html/ojs/index I had to do this so that the OJS mainsite (with all the journals available on this ojs installation) works well with the rewrite rule.
Our OJS in not live yet but so far everything seems to be fine this way.
Watch out how your journal statistics start to work. We noticed that with when we had a subdomain defined for journal1 and an ordinary domain for journal2, it was not enough to define base_url[journal1]. We also had to define base_url[journal2] and set the default journal url there. See Usage stats warnings: system can't remove the base url
So does this mean if you have, say 5 journals, journal[1-5] and journal1 is on a different domain but all others are on the same domain you still need to set up 5 base_url[journal[1-5]]?
Unfortunately, to prevent this, you will need to add re-write conditions to exclude each URL form which you want to block. If you were using RESTful URLs, you might be able to simply block direct access to index.php so that all traffic would have to go through your approved re-writes. Barring that, you will need an additional rule to check something like:
I also wanted to test to activate restful_urls in “config.inc.php” file.
But I doesn’t seem to block direct access to index.php :
NOK: Home page of OJS portal: https://openhomeportal.org/journals: display the home page of OJS journal with the list of all journals but there is a problem of css:
/journals/index/$$$call$$$/page/page/css was not found on this server
Do I have to add other rules in “htaccess” file to make RESTful URLs work ?
What is the use of RESTful URLs except to block direct access to index.php ?
Thanks again for your precious help.
Kind regards.
Helene
I have configured my OJS for multiple journals (only one at the moment) in OJS 2.4.8 with base_url[JNAME] = http://JNAME.ucc.ie
and Apache as suggested, with a VH for the JNAME serving from /var/www/html/ojs and your rewrite rules (for which many thanks). I commented out the two conditions for Apache <2.2 as we’re on 2.2.15, and added three lines in their place:
It’s all working well except for a couple of URIs.
If I log into JNAME with an author login, I correctly get the page http://JNAME.ucc.ie/user and it all looks fine, but the links behind “User Home” and “My Journals” both go to http://SERVER.ucc.ie/ojs/user which is 404. I assume this link ought to be http://JNAME.ucc.ie/user but I don’t know if this is due to some internal OJS config, or something I should trap in the rewrite rules (and I’m not clear how).
I have obviously done something wrong, but what? I certainly used to be able to login as admin (ie the link worked) and I’m not aware of changing anything that would stop it. What is the real login URI?
This ties two Rewrite Conditions to the first Rewrite Rule, and leaves the second RewriteRule with no Rewrite Conditions. I think you want the second Rewrite Rule to be conditional on the SERVER_NAME of journal1.org as well (unless this is a final catch-all after all journal-specific traffic has been handled).