I have the same problem as many others with a multijournal OJS 3.1.1.4 with multiple domains.
I get the ##api.submissions.unknownError## error for the submissions page for our journal that has its own domain: mydomain.se/
According to the error handling in Firefox it tries to find: https://mydomain.se//mydomain/api/v1/_submissions?....
which leads to a 404 error.
However this works in the address bar: https://mydomain.se/index.php/mydomain/api/v1/_submissions?....
I am using .htaccess configuration (see below) and restful_urls. I have added base_urls for all the journals. (The following settings in config.inc.php) base_url[index] = https://domain2.se base_url[journalx] = https://domain2.se/journalX base_url[mydomain] = https://mydomain.se
I think a bit of your logic in the .htaccess rules has been lost in anonymizing the content.
Most related to your issue however might be the following:
# Handle api calls in subdomains
RewriteCond %{SERVER_NAME} ^mydomain\.se$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !api\/v1\/
RewriteRule ^(.*)$ index.php/mydomain/$1 [L]
This says, if the server name is “mydomain.se” and the request does not match an existing file, and the request does not match “api/v1/”, then route the request through “index.php/mydomain”. Why exclude api requests here?
All requests to be handled by OJS (API or otherwise) are expected to be processed through OJS’s index.php.
I use the following standard re-write rule to accomplish this at the journal level:
# If the URI already has index.php in it, don't change it
RewriteCond %{REQUEST_URI} !/index.php/
# Skip existing directories if Apache 2.2 or later
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
# Skip existing files if Apache 2.2 or later
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
# Skip existing directories if Apache prior to 2.2
RewriteCond %{REQUEST_FILENAME} !-d
# Skip existing files if Apache prior to 2.2
RewriteCond %{REQUEST_FILENAME} !-f
# Rewrite all other requests to a specific journal in OJS
RewriteRule ^(.*)$ /index.php/JOURNALNAME/$1 [QSA,L]
I can confirm that this works for OJS 3.1.1-4.
My deployment uses these directives at an Apache virtualhost level, which greatly simplifies the work, because the virtualhost determines which journal is being accessed. To make this same strategy work in an .htaccess file in one Apache virtualhost which is handling multiple different domain names should be possible, but you would need to repeat this directive for each journal, with exclusion criteria so that it does not operate on every other possible domain name.
I move the settings to .conf files, and added AllowOverride None to the .conf file and/or remvoded the .htaccess file.
Then my custom domain for one of my journals “mydomain.se” redirects to the index main site “domain2.se” above.
This is my conf-file:
<Directory "/var/www/html/">
Options Indexes FollowSymLinks MultiViews
AllowOverride Fileinfo
DirectoryIndex index.php
RewriteEngine on
RewriteBase /
# If the URI already has index.php in it, don't change it
RewriteCond %{REQUEST_URI} !/index.php/
# Skip existing directories if Apache 2.2 or later
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
# Skip existing files if Apache 2.2 or later
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
# Skip existing directories if Apache prior to 2.2
RewriteCond %{REQUEST_FILENAME} !-d
# Skip existing files if Apache prior to 2.2
RewriteCond %{REQUEST_FILENAME} !-f
# Rewrite all other requests to a specific journal in OJS
RewriteRule ^(.*)$ index.php/mydomain/$1 [QSA,L]
</Directory>
It looks like the commands in .conf file are not launched, and the system needs to find the commands in the .htaccess file.
Does OJS live directly in /var/www/html here? That is, config.inc.php is found at /var/www/html/config.inc.php?
Based just on this snippet, is seems that RewriteBase / should be unnecessary. If it is added intentionally, there may be additional aliasing in place which could be affecting your re-writes.
Is this snippet contained in a single VirtualHost directive, multiple VirtualHost directives, or outside of any VirtualHost directives? There should be additional context here which may be relevant.
Did you restart Apache after modifying the config file? Changes to .htaccess will be processed immediately, but the config files are only reloaded after an Apache restart.
Yes, it is. However we might want to move it into a subfolder in future.
I tried both with and without that.
Yes, the file looks like this: <VirtualHost *:80> ServerName mydomain.se DocumentRoot "/var/www/html/"
…snippet above… ErrorLog "/var/log/httpd/xxx:80_error.log" ServerSignature Off CustomLog "/var/log/httpd/xxx:80_access.log" combined </VirtualHost>
And then I have a similar file for the 443 port with generally the same content. And then a 80 and a 443 file for the main site.
What actually happens when you try to access the server with this configuration? Do you get a server error, a redirect loop, or a partially loaded page?
Have you tried enabling the mod_rewrite logging to see what Apache is processing with the request?
The problem with conf-files and .htaccess seemed to be related to the !-d command. Here is an output from the logging: RewriteCond: input='/' pattern='!/index.php/' => matched RewriteCond: input='/var/www/html//' pattern='!-d' => not-matched
The log lines are related to an index request (no path provided in the URI). They indicate that such a request matches the pattern of “does not contain /index.php/”, and does not match the criteria of “is not a directory”. The input “/var/www/html//” is a valid directory.
Do you have DirectoryIndex index.php set in your virtualhost? This enables Apache to respond to a directory request with the index.php file it contains.
It looks like the Rewrite-rules are adding “mydomain” to the URI multiple times.
I modified my apache conf-file by adding a RewriteCond to look for “mydomain” in the address.
Now my .conf file looks like this:
<VirtualHost *:443>
ServerName mydomain.se
DocumentRoot "/var/www/html/"
<Directory /var/www/html>
AllowOverride None
Options Indexes FollowSymLinks MultiViews
Require all granted
DirectoryIndex index.php
RewriteEngine on
RewriteBase /
# If the URI already has index.php in it, don't change it
RewriteCond %{REQUEST_URI} !/index.php/
RewriteCond %{REQUEST_URI} !/mydomain/
# Skip existing directories if Apache 2.2 or later
#RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
# Skip existing files if Apache 2.2 or later
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
# Rewrite all other requests to a specific journal in OJS
RewriteRule ^(.*)$ index.php/mydomain/$1 [QSA,L]
# If the URI already has index.php in it, don't change it
RewriteCond %{REQUEST_URI} !/index.php/
RewriteCond %{REQUEST_URI} /mydomain/
# Skip existing directories if Apache 2.2 or later
#RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
# Skip existing files if Apache 2.2 or later
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
# Rewrite all other requests to a specific journal in OJS
RewriteRule ^mydomain(.*)$ index.php/mydomain/$1 [QSA,L]
</Directory>
## Logging
ErrorLog "/var/log/httpd/mydomain.se:443_error_ssl.log"
ServerSignature Off
CustomLog "/var/log/httpd/mydomain.se:443_access_ssl.log" combined
## Header rules
## as per http://httpd.apache.org/docs/2.2/mod/mod_headers.html#header
Header Set Strict-Transport-Security "max-age=31536000"
## SSL directives
...
</VirtualHost>