[OJS 3.1.2-1] Journal statistic

Hello,

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:

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

It works fine but not for the following URL:
https://journal-domain1.fr/api/v1/stats/publishedSubmissions

There is a “404 Not Found” error.

I tried several additional rules but it doesn’t work.

Is anyone has an idea ?

Thanks in advance.
Best regards.
Helene

@hcl Can you tell me if this url will return any result? I can not test your dns.

https://journal-domain1.fr/index.php/journal1/api/v1/stats/publishedSubmissions

Dung.

Hi @dung,

Yes, the following URL works:
https://journal-domain1.fr/index.php/journal1/api/v1/stats/publishedSubmissions

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?

Thanks again.
Best regards.
Helene

Hello @hcl,

Try to replace your 5 lines above with theses

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]

Next time please send the entire section

<VirtualHost *:443>
...
...
...
</VirtualHost>

Hi @dung,

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/

On the other hand, I noticed that when I remove {contextPath} in “/lib/pkp/classes/handler/APIHandler.inc.php” file in “getEndpointPattern” function the following URL works:
https://journal-domain1.fr/api/v1/stats/publishedSubmissions

But it’s not the solution for all journals.

Best regards.
Helene

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.

Hi @asmecher,

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:

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

It works fine for all URL such as:

But not for the following URL:
https://journal-domain1.fr/api/v1/stats/publishedSubmissions
There is a “404 Not Found” error.
But the following URL works:
https://journal-domain1.fr/index.php/journal1/api/v1/stats/publishedSubmissions

And I noticed that when I remove {contextPath} in “/lib/pkp/classes/handler/APIHandler.inc.php” file in “getEndpointPattern” function the following URL finally works:
https://journal-domain1.fr/api/v1/stats/publishedSubmissions

But it’s not the solution for all journals.

Can you explain me the reason why and what can I do to solve this ?

Thanks in advance for your answer.
Best regards.
Helene

Hi @hcl,

This is filed and will get attention soon at API calls fail if context path is obscured by RESTful URL configuration · Issue #4919 · pkp/pkp-lib · GitHub – I’d suggest watching that issue for an update.

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

3 posts were split to a new topic: [OJS 3.1.2.4] Blank statistics after upgrade

Has anyone resolved an issue with blank statistics view? More about this is written at [OJS 3.1.2.4] Blank statistics after upgrade - #8 by Lazar_Stosic but the problem still exist.