Each journal with its own domain name


#21

@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:

<VirtualHost *:80>
	<Directory /var/www/html/ojs>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride All
		Order allow,deny
		allow from all
		
		RewriteEngine on
		RewriteRule ^/(index.php)?/?$ /ojs/index.php/test1/index [L]
		RewriteRule ^/test1/(.*)$ /$1 [R,L]
		RewriteCond %{REQUEST_URI} !/index.php/
		#RewriteCond %{DOCUMENT_ROOT}ojs%{REQUEST_URI} !-d
		#RewriteCond %{DOCUMENT_ROOT}ojs%{REQUEST_URI} !-f
		RewriteCond %{REQUEST_FILENAME} !-d
		RewriteCond %{REQUEST_FILENAME} !-f
		RewriteRule ^(.*)$ /ojs/index.php/test1/$1 [QSA,L]
		RewriteCond %{DOCUMENT_ROOT}ojs%{REQUEST_URI} -f
		RewriteRule ^(.*)$ /ojs/$1 [QSA,L]
		
	</Directory>
...

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.


#22

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:

DocumentRoot /var/www/html/ojs/
base_url[test1] = http://test1.domain/

#23

Sorry for the late reply but the flu got me again for a few days.

I switched the document roots of all the virtual hosts to /var/www/html/ojs, e.g. test1.conf

<VirtualHost *:80>
	<Directory /var/www/html/ojs>
		...
		RewriteEngine on
		RewriteRule ^/(index.php)?/?$ /ojs/index.php/test1/index [L]
		RewriteRule ^/test1/(.*)$ /$1 [R,L]
		RewriteCond %{REQUEST_URI} !/index.php/
		#RewriteCond %{DOCUMENT_ROOT}ojs%{REQUEST_URI} !-d
		#RewriteCond %{DOCUMENT_ROOT}ojs%{REQUEST_URI} !-f
		RewriteCond %{REQUEST_FILENAME} !-d
		RewriteCond %{REQUEST_FILENAME} !-f
		RewriteRule ^(.*)$ /ojs/index.php/test1/$1 [QSA,L]
		RewriteCond %{DOCUMENT_ROOT}ojs%{REQUEST_URI} -f
		RewriteRule ^(.*)$ /ojs/$1 [QSA,L]
	</Directory>
	ServerName test1.domain 
	ServerAdmin webmaster@localhost
	DocumentRoot /var/www/html/ojs
	...
</VirtualHost>

This is config.inc.php

base_url = "http://journals.uni-giessen.de"
...
base_url[index] = http://journals.uni-giessen.de/ojs/index
base_url[test1] = http://test1.domain
base_url[test2] = http://test2.domain
...
restful_urls = Off

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.”).

Enabling restful_urls also had no effect.


#24

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


#25

The Apache is 2.4 but the %{REQUEST_FILENAME} variable seem to work fine.

I tried a fresh approach using a config from a colleague and i nearly got it. The apache vhosts point to:

ServerName = journals.uni-giessen.de document_root = /var/www/html/ojs

These are the relevant lines of config.inc.php

base_url = "http://journals.uni-giessen.de"
base_url[test1] = http://test1.domain
restful_urls = On

If moved the rewrite rules to a .htaccess file again

RewriteEngine On
## test1
RewriteCond %{SERVER_NAME} ^(www\.)?test1.domain
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php/test1/$1 [QSA,L]
## test2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^test2(.*)$ /index.php/test2/$1 [QSA,L]

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

href="http://journals.uni-giessen.de/index/$$$call$$$/page/page/css?name=stylesheet

The link should be:

href="http://journals.uni-giessen.de/index.php/index/$$$call$$$/page/page/css?name=stylesheet"

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.

Has anyone ideas for the remaining problems?


#26

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:
http://forum.pkp.sfu.ca/t/problem-rendering-glyphicons-in-ojs-3-0-0/23311


#27

I added the following rule at the end of the .htaccess file:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^index/(.*)$ /index.php/index/$1 [QSA,L]

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).

Thank you for the support.


#28

Dear florianruckelshausen,

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

Best regards


#29

See also @ajnyga’s post here:
http://forum.pkp.sfu.ca/t/how-to-remove-index-php-in-ojs-3-0-2-0/28939/10?u=ctgraham


#30

@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

RewriteEngine On
RewriteBase /
## RMM has its own domain
RewriteCond %{SERVER_NAME} ^(www\.)?rmm-journal.de
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php/rmm/$1 [QSA,L]
## test2 just index.php stripping
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^test2(.*)$ /index.php/test2/$1 [QSA,L]
## Mainsite of OJS with journal overview
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^index/(.*)$ /index.php/index/$1 [QSA,L]

I didn’t use RewriteCond %{REQUEST_FILENAME} !-d because it made some trouble and it seems to work without it.

  • Set up OJS config.inc.php. Here are the relevant lines that worked for me
base_url = "http://journals.uni-giessen.de"
...
base_url[index] = http://journals.uni-giessen.de/index
base_url[rmm] = http://rmm-journal.de
base_url[test2] = http://journals.uni-giessen.de/test2
...
restful_urls = On
  • 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.


Custom domain, 443 settings, 404 ERROR page
#31

Congratulations @florianruckelshausen,

Thank you very much for sharing this with us!

Can you please take a bit of time, and add a bit of documentation to: OJS Documentation Wiki?

This is a very often asked question and your directions would be very useful to the community.

Regards


#32

This worked for us also although rather than catching the individual journals and redirecting to sub directories we used the existing catch all.

We have all but one journal on http://journals.knowledgearc.com/, so http://journals.knowledgearc.com/journal1, http://journals.knowledgearc.com/journal2, etc. However, one of our journals, journal3, is on a completely different domain, I.e. http://completely.different.domain. So we used the following in htaccess:

RewriteEngine On
RewriteBase /
## journal3
RewriteCond %{SERVER_NAME} ^completely.different.domain
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php/journal3/$1 [QSA,L]
## All other journals
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php/$1 [QSA,L]

The first checks for completely.different.domain and redirects to journal3. All other journals just get sent to http://journals.knowledgearc.com.

In config.inc.php

base_url[journal3] = http://completely.different.domain

we didn’t need to set base_url[index].


#33

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


#34

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]]?


#35

Basically yes, when you are using a single installation of OJS.

In our case if I have site.com/journal1 and journal2.site.com, I have to define both although only journal2 has a special url:
base_url[journal1] = http://site.com/journal1
base_url[journal2] = http://journal2.site.com

This of course comes a bit annoying when you have a lot of journals (we have around 60).

But I suggest that you test what happens in your case. Just see if all your journals get statistics after defining that one special base_url.


#36

Hi,

We are using OJS31, 3.1.0-1 exactly.

We host several journals with their own domain name.

So we have an “.htacess” file with RewriteRule directives like this:

RewriteEngine On
RewriteCond %{SERVER_NAME} ^(www.)?journal1.org
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php/journal1/$1 [QSA,L]

RewriteCond %{SERVER_NAME} ^(www.)?journal2.org
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php/journal2/$1 [QSA,L]

And here is an example of our “config.inc.php” file:

base_url = "https://openhomeportal.org/journals"
disable_path_info = Off
allow_url_fopen = Off
base_url[journal1] = https://journal1.org
base_url[journal2] = https://journal2.org
restful_urls = Off

And here is a part of our Apache (2.4) config file for portal home page:

ServerName journalsportal.org
DocumentRoot /var/www/

(we have other content that journals under URL openhomeportal.org.org)

And here is a part of our Apache (2.4) config file for a specific journal with its own domaine name:

ServerName journal1.org
DocumentRoot /var/www/journals

Those URL work fine:
Home page of OJS portal: https://openhomeportal.org/journals: display the home page of OJS journal with the list of all journals
Journal1: https://journal1.org: display the home page of Journal1
Journal2: https://journal2.org: display the home page of Journal2

But there is big mismatch between URL:
At first, https://journal1.org/index.php or https://journal2.org/index.php display content of Home page of OJS portal (https://openhomeportal.org/journals) instead of content of journal home page.
But the biggest problem is https://journal1.org/index.php/journal2 display content of journal2 and https://journal2.org/index.php/journal1 display content of journal1
So google references articles of journal2 inside the journal1 and vice versa.
It’s very detrimental for journals.
I tested many possibilities of configuration in “.htacess” file with RewriteRule directives but nothing work to prevent URL https://journal1.org/index.php to display content of Home page of OJS portal (https://openhomeportal.org/journals) instead of content of journal home page and so on https://journal1.org/index.php/journal2 to display content of journal2.

I would be very grateful for your help.
Thanks in advance.
Best regards.
Helene


#37

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:

  • is the SERVER_NAME not journal1.org
  • does the REQUEST_FILENAME include /index.php/journal1
  • Rewrite to 404

#38

Hi @ctgraham,

Thanks a lot for your swift reply!

I added an additional rule in “htaccess” file:

RewriteCond %{SERVER_NAME} ^(www.)?journal1.org
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.)$ /index.php/journal1/$1 [QSA,L]
RewriteRule ^(.
)/journal2/(.*)$ /404 [L,R]

I thought it was working because URL https://journal1.org/index.php/journal2 was redirected to 404 but https://journal2.org/ isn’t working anymore.
Could you give me some help to write the proper RewriteRule ?

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 :

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


#39

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:

# snag bogus references to /public, /plugins, /styles
RewriteRule ^/public/(.*)$ http://SERVER.ucc.ie/ojs/public/$1 [QSA,L]
RewriteRule ^/plugins/(.*)$ http://SERVER.ucc.ie/ojs/plugins/$1 [QSA,L]
RewriteRule ^/styles/(.*)$ http://SERVER.ucc.ie/ojs/styles/$1 [QSA,L]

It’s all working well except for a couple of URIs.

  1. 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).
  2. The generated links fail on the Step 1 page for “Author Guidelines” (http://JNAME.ucc.ie/ojs/index.php/JNAME/about/submissions#authorGuidelines) [404] and “Ensuring a Blind Review” (javascript:openHelp(‘http://SERVER.ucc.ie/ojs/index.php/JNAME/help/view/editorial/topic/000044’)) [nothing happens although the embedded URI does work if pasted manually].
  3. If I log out and go to http://SERVER.ucc.ie/ojs I get the base home page but the login link goes to http://SERVER.ucc.ie/ojs/login/signIn which is 404, so I cannot sign in as admin to fix anything inside OJS!

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?

P


#40

@hcl, the purpose of the RESTful URLs is to remove index.php from the public presentation of the URL.

I don’t think the example you give functions the way you want.

RewriteCond %{SERVER_NAME} ^(www.)?journal1.org
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.)$ /index.php/journal1/$1 [QSA,L]
RewriteRule ^(.)/journal2/(.*)$ /404 [L,R]

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).