RESTful URL woes with 3.0

Hi there,

I’m working on establishing an OJS install and I have some challenge with RESTful URLs.

Here are some symptoms:

  • The system works fine with RESTful URLs disabled.
  • Enabling RESTful URLs forces the system into a redirect loop. Chrome times out with an “TOO_MANY_REDIRECTS” error
  • When the system is in a redirect loop, I know that there is some PHP work being done because my error log fills up with Strict Standards violations.

Environment information:

  • OJS lives in a subdomain, with a separate document_root than the main domain, to avoid rewrite rule conflicts.

Any ideas?

Hi @KevinHarding,

Have you added the rewiting rules per docs/FAQ to go with the RESTful URL setting?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi Alec -

Thanks for asking. I should have included the info:

  • I’ve used the rewrite rules as per the FAQ into an .htaccess.

  • Using the .htaccess rules from the FAQ as is, I get a redirect loop.

  • Putting a / before index.php in the final rewrite rule gives me a redirect loop.

  • Adding in RewriteBase / but without the / before index.php, I get a redirect loop.

  • Adding in RewriteBase / and a / before index.php, I get a redirect loop.

  • Disabling PATH_INFO (setting the disable_path_info = On) everything renders properly, but of course it’s not a clean URL.

When I enable restful URLs with the rewrite rules in the htaccess, and visiting a URL with index.php in it (defeating the RewriteRule !-f condition), HTML loads but no styling, and the CSS doesn’t load because the CSS file is in a redirect loop.

Please detail your filesystem layout and explicitly describe what you currently have in your .htaccess file and where it lives.

For example, in my configuration, OJS lives one folder off of DocumentRoot, in “/ojs”. My rewrite rules are at the DocumentRoot level, and specify:

   # For Apache < 2.2
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-f
   # For Apache 2.2 and greater
   RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
   RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
   # Do not rewrite URI with /index.php/ as a path component
   RewriteCond %{REQUEST_URI} !^.*/index.php/.*$
   # Rewrite non-file, non-directory URLs to OJS's index.php
   RewriteRule ^/ojs/(.*)$ /ojs/index.php/$1 [QSA,L]

The OJS system exists on a subdomain (http://journal.domain.com) and the document root of the subdomain is /home/user/journal.

OJS lives directly in /home/user/journal, and the config.inc.php and .htaccess file both exist there. There shouldn’t be any overlap with the Wordpress .htaccess for the main domain (http://domain.com) because the document roots are different.

Currently, the .htaccess contains ONLY the following:

<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,L] </IfModule>

I can share links, if it would help at all.

What is the URI that is causing the redirect loop?

What version of Apache are you running? Instead of your current RewriteConds, try:

   RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
   RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f

Hi, I got the same issue "ERR_TOO_MANY_REDIRECTS” error
here the information:
domain: http://domain.org
document folder (root): /home/user/public_html/
htaccess file on /home/user/public_html/.htaccess
htaccess:

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

Server Information

Item Detail
Hosting Package default
Server Name server
cPanel Version 86.0 (build 17)
Apache Version 2.4.41
PHP Version 7.3.16
MySQL Version 10.0.38-MariaDB
Architecture x86_64
Operating System linux

Try adding an exclusion to avoid re-writing URLS which already have index.php in them.