We got stats to display correctly now for all custom domains journals (e.g … https://cdm.ucalgary.ca) it was the api url not resolving correctly. To fix this we made the following changes in file: /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:443>
...
# Rewrite custom domain to make api calls correctly
RewriteRule ^/(api/.*)$ /index.php/cdm/$1 [R,L]
...
</VirtualHost>
# Before applying the RewriteRules, the below uri is not found error 404
https://jmss.org/api/v1/stats/publishedSubmissions?count=20&offset=0&dateStart=2019-05-20&dateEnd=2019-06-19&timeSegment=month&orderBy=total&orderDirection=DESC&_=1561096128768
# After applying the following RewriteRules, the below uri works
# Rewrite custom domain to make api calls correctly
RewriteRule ^/(api/.*)$ /index.php/jmss/$1 [R,L]
https://jmss.org/index.php/jmss/api/v1/stats/publishedSubmissions?count=20&offset=0&dateStart=2019-05-20&dateEnd=2019-06-19&timeSegment=month&orderBy=total&orderDirection=DESC&_=1561096128768
@dung, thank you! However this does not seem to work in our case. And I still suspect there is some bug here. For we have already had a rewriting rule, that should work for all such cases. Here it is:
@Ph_We Hi, Where did you put your RewriteRules? Show me the RewriteRules section if you can. Your RewriteRules is wrong in relation to Statistic and you are almost there.
If you want to do RewriteRules in virtualhost sections here is how: in your /etc/apache2/site-enabled/ find your config file such as 000-default.conf and add each section like the below for every journal.
<VirtualHost *:443>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerName abcd.org
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/gjhgjgjern
RewriteEngine On
# Rewrite index requests to the journal index
RewriteRule ^/(index.php)?/?$ /index.php/abcd/index [L]
# Rewrite custom domain to make api calls correctly
RewriteRule ^/(api/.*)$ /index.php/abcd/$1 [R,L]
# if the incoming request references the journal shortname, use an external redirect to strip the journal shortname
RewriteRule ^/abcd/(.*)$ /$1 [R,L]
# Normal request processing
# Ignore if this request references index.php already
RewriteCond %{REQUEST_URI} !/index.php/
# Ignore if request is for a known OJS directory (Apache 2.2+)
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-d
# Ignore if request is for a known OJS file (Apache 2.2+)
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
# Otherwise, rewrite all requests through index.php to this specific journal shortname
RewriteRule ^(.*)$ /index.php/abcd/$1 [QSA,L]
SSLEngine On
SSLCertificateFile /sdfdf/asdfdf/cxvxcv/dfsdfds.crt
SSLCertificateKeyFile /sdfdf/asdfdf/xcvxcvxc/sdfsdfd.key
SSLCertificateChainFile /sdfds/apsdfs/xcvxcvxc/sfsdfsdfs.crt
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info xcvxcvxcv:warn
ErrorLog ${APACHE_LOG_DIR}/brwqrwsf_error-xvcxv.log
CustomLog ${APACHE_LOG_DIR}/sfweradsa_access-dsdsdsa.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
Or if you want to stick with RewriteRules in .htaccess you will need to resolve that error 404 Not Found and your Statistic will work, we had the exact same issue and we fixed that with rules:
Rewrite custom domain to make api calls correctly
RewriteRule ^/(api/.*)$ /index.php/abcd/$1 [R,L]
Where “abcd” is your “mirros”
This is what you api should return then the Stat will show
We’ve only managed to set up rewriting for this certain journal out of 23 so far. And this had to be set up in both .htaccess and VirtualHost. @dung, thanks once again.
@asmecher, (just to make it clear) Is there a reason why this certain API call should be different from any other? It might be really difficult to set this up in some cases.
We are using OJS 3.1.2-1 We host several journals which have their own domain name.
We have the same problem. Some statistic pages do not display with a “404 Not Found” error.
We have rewrite rules in .htaccess file like this:
I don’t understand why, by the way. I thought my rewrite rule skipped all “index.php/journal1” url part.
Do you have any idea of which additional rule should I have to add to make it work?
RewriteEngine On
# Rewrite index requests to the journal index
RewriteRule ^/(index.php)?/?$ /index.php/journal1/index [L]
# Rewrite custom domain to make api calls correctly
RewriteRule ^/(api/.*)$ /index.php/journal1/$1 [R,L]
I can’t send the entire section of VirtualHost because our rewrite rules are not in VirtualHost but in .htaccess file.
The rewrite rules you suggest don’t work for us because it changes all the previous rules and journals are not accessible any more to the base url: https://journal-domain1.fr/
Please read [OJS 3.1.2-1] Journal statistic - #13 by Ph_We
Sorry that I can not help with .htaccess. I have always used virtual host configuration - the recommended and not complicated way of doing this.
I’m writting to you for this topic to ask you if you know the reason why URLs of stats with “api/v1” don’t work like other URLs when we have rewrite rules ?
We have rewrite rules in .htaccess file like this: