[3.1.2.0] OJS auto-forwards missing files to Search form, preventing .htaccess redirects

This OJS 3.1.2.0 functionality: [OJS 3.2.4.1] Readers can't view pdfs - #6 by asmecher auto-forwards links to missing public files to the built-in Search form.

We tried virtually every .htaccess redirect command that there is, and none is working - a missing file (say, withdrawn article, reissued article, a corrected article under new ID, etc.) is always redirected to Search regardless.

Q1: Can the above PHP code (the line 542: $request->redirect(null, 'search');) be safely removed or edited in a way that ensures bypassing of this functionality, meaning allowing for .htaccess redirects to work normally?

Q2: If there isn’t, is there a direct .htaccess command/some Apache server settings that would enable .htaccess redirects to bypass the above functionality/enable .htaccess to take precedence over OJS in this regard?

Hi @otisisto,

It’s possible to intercept the request for the URL before it hits OJS, but that’s 100% an Apache configuration question, so you might have better luck e.g. on StackOverflow.

After OJS has encountered the URL and attempts to redirect to /search, there typically aren’t good ways for Apache to intervene. You might be best off just modifying that line of code to redirect elsewhere, if that’s your goal.

For the future, we’re planning make better use of exceptions for handling cases like these, and then to make the handling of those exceptions more flexible – both to modernize error handling, but also to move us closer to adopting Laravel for more of the routing/dispatching framework. But that’s a while in the future yet.

Note that OJS 3.1.2 is quite obsolete – I’d strongly suggest upgrading soon.

Regards,
Alec Smecher
Public Knowledge Project Team

This topic was automatically closed after 10 days. New replies are no longer allowed.