Single journal url .htaccess configuration

It looks like you do not have full administrator privileges on your install. Do you have access to the admin account? There should be a Site Settings option if you have administrator privileges.

I would recommend a install of OJS is the document root of www.aghamx.com, with a simple mod_rewrite to strip off the index.php, enabling restful_urls. Use the Journal Redirect to go to your journal automatically.

This would require no custom base_url overrides. It would give your journal a base url of http://www.aghamx.com/aghamx. Any access to http://www.aghamx.com would automatically redirect to http://www.aghamx.com/aghamx. Your site management would be accessible at http://www.aghamx.com/index.

The mod_rewrite rule would be as simple as:

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

(But note that this rule will still depend on your specific server configuration!)

If you really only ever intend to host the one journal, you might be able to improve the URL by using a journal shortname of “journal” or “pubs” or similar, for a journal URL of http://www.aghamx.com/pubs/, so “aghamx” does not repeat in the URL.

If you need to get the journal’s root down to the domain route, this is possible, but it really does require special expertise with mod_rewrite and is extremely situation dependent.

Hi @ctgraham

I thought I was using the admin account because it was the account I entered during the first installation. I don’t know how I don’t seem to have admin privileges. In order to make sure I had not made an error somewhere during the installation, I did a fresh installation in localhost, entered a new account, then immediately tried to navigate to the site settings but also found none. I navigated to the role settings and it is indicated that the account Im using (which I created during installation and should be the site admin), is journal manager. I think this is exactly the same case happening in the live website. What do you think might be wrong? How could I get those admin privileges? Hopefully without doing a fresh installation in the web server…

Btw, I tried the mod rewrite rule you suggested but still without success. Maybe it would work once the journal redirect settings are corrected.

Also, I think that’s a really good solution, I will be setting the journal URL to www.aghamx.com/journal so the remaining concern would only removing index.php.

Thank you for the support! Hopefully this gets fully resolved soon! :slight_smile:

What specific version of OJS are you using (including the last “dot release”)? When you tried a clean install on localhost, did you have the installer create a new database, or did you already have a database?

I’m using 3.0.1. Oh yes, about that, I could not create a new database and the installation could not proceed. I just did the installation in localhost yet again to make sure. And now I remember that I’ve been getting “A database error has occurred: Access denied for user…”
Only way I could resolve it was create a new database in phpmyadmin in hostgator cpanel and then created a new user and elevated its privileges to that database. And then I entered the database and the user to the OJS Installation and OJS installation was successful… hmmm… Could this be the reason?

I would be primarily concerned about installing “over top” of an existing database. If you have a blank database created in phpmyadmin which the OJS install populates, or if you have the installer create the database, I would expect the user your specify in the installation form to get full admin privileges.

I replicated the problem of the Site Settings not displaying in 3.0.1 and 3.0.2. I was able (in 3.0.2) to manually enter the URL of “index.php/index/admin/settings” and to pull up and to save the Site Settings as the administrator. Manual access to index.php/index/admin/settings is inconclusive. I’ve found the Site Settings will only show if more than one journal is defined. I’m going to gather a bit more information and then file a bug report.

Do you have an Apache DirectoryIndex directive which applies a priority to anything over index.php? I had:
DirectoryIndex index.html index.php
and this caused PHP’s PATH_INFO to be malformed under mod_rewrite.

Changing this to DirectoryIndex index.php allowed OJS to behave as expected, with the Site index automatically redirecting to the Journal index for a single journal install.

Hi @ctgraham :slight_smile:

As per your suggestion, I put a DirectoryIndex line in my htaccess config

DirectoryIndex index.php

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

Going to aghamx.com would then redirect to http://www.aghamx.com/journal but returns a 404 error. Going to aghamx.com would load the homepage but displays incorrectly. Also, I could still not find the Site Settings in the admin dashboard.

These lines won’t work for you:

RewriteCond %{REQUEST_URI} !^./index.php/.$
RewriteRule ^/aghamx/(.*)$ /aghamx/index.php/$1 [QSA,L]

They say: the next RewriteRule applies only to requests which don’t start with any character, followed immediately by the literal “/index.php/”, and ending exactly in one character. Then, for any request that matches that and starts exactly with “/aghamx/” followed by any captured characters, redirect the request to index.php under the aghamx folder, with the captured characters apended.

The two regular expressions are contradictory.

Try directives of:

  RewriteCond %{REQUEST_URI} !^.*/index.php/.*$
  RewriteRule ^/(.*)$ /index.php/$1 [QSA,L]

Hi @ctgraham

Sorry I’ve been busy the past days. I implemented those lines but I don’t observe any effect in the URL.

What specifically do you mean by “don’t observer any effect in the URL”?

Do you still have restful_urls on in your config.inc.php?

I have the same issue, I can not see the SITE SETTING in

Admin → Administration → Site Settings → Journal redirect

In my case there is no other users, and the only user is the one who installed the OJS 3.0.2.0.

When I try to access , It get

…/index.php/index/user/authorizationDenied?message=user.authorization.accessDenied

I don’t find it either as the journal admin

@kawahyu, do you have a site with multiple journals, or with a single journal? This option will only appear if your site has multiple journals.

@Dilan_Rostam, I wonder if this thread might be relevant to your error message:

1 Like

Sorry, I think it will appear for all. I manage single journal.

Thanks

I wish that one single easy option could MASK the long OJS URL to a short custom version. Such as

http://mydomain.com/index.php/MyJournal

http://mydomain.com/MyJournal

and if one journal to

http://mydomain.com/

Is there any new release of OJS on the way please? I thought the issue with Static page menu item will be addressed in new release, am I right?

I have the same situation. My single journal is on the subdomain http://journal.domain.com Now setup in config.inc.php:

base_url[index] = http://journal.domain.com
base_url[journal] = http://journal.domain.com/journal
restful_urls = On

and .htaccess file:

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

Now the site opens with http://journal.domain.com/journal. How to remove the trailing /journal? That is, that the site opened by URL http://journal.domain.com

Dear @ctgraham
I would like to continue on this as I was upgrading from 3.1.2.4 → 3.2.1.2 an encountered the issue of redirecting API calls . I just want this single journal on the site with pretty URLs without having to fiddle with .htaccess except for enabling RESTful URLs.
So I inspected the code for the $site->getRedirect() and related.

First: I could not quite find out what the setting in the db actually does.
Second: As I understood the redirect setting should be in https://github.com/pkp/pkp-lib/blob/master/templates/admin/contextSettings.tpl , but there is not even code for it. Is it really missing?

Maybe @NateWr and @asmecher could clarify what redirect :: true/false actually does and how to get there.

Thanks for your help and all the best
Klaus

Hi, @klausru.

Can you describe the problem you are seeing with redirecting API calls in 3.2.1-2? The issue #4919 is believed resolved as of 3.2.x.

In older versions of OJS, you could set a redirect at the site level to a specific context (journal). In 3.2, I think this is automatic in the case of a single journal installation.

Can you clarify what code you are looking at with respect to redirect :: true/false?

Dear @ctgraham

the issue is as here: SOLVED: Upgrade from OJS 3.1.2.4 to OJS 3.2.1.2: problems with url api in back-office
or here: [OJS 3.2.0.3] Error on Submission Page - #22 by drugurkocak

base_url = "https://www.medienpaed.com"
base_url[medienpaed] = https://www.medienpaed.com
restful_urls = On

I pretty much tried all of those .htaccess rewrite rules but none really work. They either 404 or 500 for the whole site or they don’t properly affect the API calls. My current .htaccess is (from: [Solved] Problems with api submissions error on submissions page - #10 by ctgraham):

# If the URI already has index.php in it, don't change it
RewriteCond %{REQUEST_URI} !/index.php/
RewriteCond %{REQUEST_URI} !/medienpaed/
# 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/medienpaed/$1 [QSA,L]

# If the URI already has index.php in it, don't change it
RewriteCond %{REQUEST_URI} !/index.php/
RewriteCond %{REQUEST_URI} /medienpaed/
# 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 ^medienpaed(.*)$ index.php/medienpaed/$1 [QSA,L]

Too bad that this code only removes the error message and puts the API request in some loop, without any effect (bonkers?). Thus I can’t use filters on submissions etc.
As earlier posts mentioned that redirect in site table should make redirecting single journal instances very easy, I started to try to figure out what this actually does. Its value used to be set to "1". A fresh install sets or leaves the value on “0”. But changing the value has no effect.

Any idea?

Solved with this solution: [OJS 3.2.0.3] Error on Submission Page - #24 by KBodarwe

I don’t know why it did not work before, but for now it’s fine.