Please, How To Direct Single Journal To Web Root (http://journalpage.com) instead of (http://journalpage.com?index.php/ojs)

Hi All,

We’ve struggled with a single journal site with pretty URLs for ages, tried various solutions posted in this thread and other places but had lots of errors all over the place.

Here’s what currently works best for us, haven’t had any error so far:

Site: https://ijpds.org
Journal Name: ijpds

Apache rewrite config:

    RewriteEngine on

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

    RewriteRule "^\/$" "/index.php/ijpds/" [PT]

    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !api/v1/
    RewriteRule ^(.*)$ /index.php/ijpds/$1 [QSA]

OJS conf file snippets:

base_url = “https://ijpds.org
base_url[index] = International Journal of Population Data Science
base_url[ijpds] = https://ijpds.org
restful_urls = On

It’d be nice to hear from others what they had to do! :slightly_smiling_face:

Thanks @imranh! Your recipe worked! Only in the URL to the main page appears the second slash before ‘index’, for your example International Journal of Population Data Science and it appears in the URL everywhere except for static pages

Glad to hear it worked :slight_smile:!

Not the end of the world, I think this’ll fix it if it bothers you:

Change RewriteRule ^(.*)$ /index.php/ijpds/$1 [QSA] to RewriteRule ^(.*)$ /index.php/ijpds$1 [QSA]

@imranh I tried this option. The site is loaded, but unfortunately all styles and some scripts (except external) are not loaded. Also, the navigation menu is not loaded in the frontend and all that is generated via JavaScript is not loaded in the backend ((
By the way, in the original solution some of the added scripts cease to work, for example, lightgallery.js issue an error SecurityError (DOM Exception 18): Blocked attempt to use history.replaceState() to change session history URL to http://article/view/42#lg=1&slide=0. Protocols, domains, ports, usernames, and passwords must match. in the console.

This is a setup that works for me with OJS 3.1.1.2. It includes a redirect to handle the troublesome API calls that have been returning an error in some cases. I do not have this in production use, so comments are welcome. Just a pointer that this was very handy while testing the rules: https://htaccess.madewithlove.be/

config.inc.php

base_url = "http://domain.net"
base_url[JOURNALPATH] = http://domain.net

.htaccess

RewriteEngine On

# Redirect calls to domain root to /index path
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.net [NC]
RewriteRule ^/?$ http://domain.net/index [L,R=301]

# Redirect api calls
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} api/v1/
RewriteRule ^(.*)$ index.php/$1 [QSA,L]

# Redirect ordinary calls with a path
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/JOURNALPATH/$1 [QSA,L]

Edit: this works up to the point that if you go to your dashboard and try to access the administration tab, you will get a 404 because of the redirect above. It can be probably fixed with some additional redirects. Of course in a single journal installation, there is a limited need for access to the admin tab anyway, I guess.

1 Like

I tried using these (both the above) codes @imranh and @ajnyga , however it doesnt work.

The articles are available on www.domain.com/article/view/243 for ex, however the redirects are not working, so it still shows www.domain.com/journalpath/article/view/243 and gives a 404 Not found error.

image

Error logs:

[30-Dec-2018 12:08:34 UTC] PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Smarty has a deprecated constructor in /home/u741823471/domains/jmedresinnovation.org/public_html/lib/pkp/lib/vendor/smarty/smarty/libs/Smarty.class.php on line 64
[30-Dec-2018 12:08:34 UTC] PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; ADODB_Cache_File has a deprecated constructor in /home/u741823471/domains/jmedresinnovation.org/public_html/lib/pkp/lib/adodb/adodb.inc.php on line 263
[30-Dec-2018 12:08:34 UTC] PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; ADOConnection has a deprecated constructor in /home/u741823471/domains/jmedresinnovation.org/public_html/lib/pkp/lib/adodb/adodb.inc.php on line 359
[30-Dec-2018 12:08:34 UTC] PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; ADORecordSet has a deprecated constructor in /home/u741823471/domains/jmedresinnovation.org/public_html/lib/pkp/lib/adodb/adodb.inc.php on line 2921
[30-Dec-2018 12:08:34 UTC] PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; ADORecordSet_array has a deprecated constructor in /home/u741823471/domains/jmedresinnovation.org/public_html/lib/pkp/lib/adodb/adodb.inc.php on line 3939
[30-Dec-2018 12:08:34 UTC] PHP Warning: Declaration of PKPUsageEventPlugin::getEnabled() should be compatible with LazyLoadPlugin::getEnabled($contextId = NULL) in /home/u741823471/domains/jmedresinnovation.org/public_html/lib/pkp/plugins/generic/usageEvent/PKPUsageEventPlugin.inc.php on line 386
[30-Dec-2018 12:08:34 UTC] PHP Warning: Declaration of DRIVERDAO::setOAI(&$oai) should be compatible with PKPOAIDAO::setOAI($oai) in /home/u741823471/domains/jmedresinnovation.org/public_html/plugins/generic/driver/DRIVERDAO.inc.php on line 19
[30-Dec-2018 12:08:34 UTC] PHP Warning: Declaration of OpenAIREDAO::setOAI(&$oai) should be compatible with PKPOAIDAO::setOAI($oai) in /home/u741823471/domains/jmedresinnovation.org/public_html/plugins/generic/openAIRE/OpenAIREDAO.inc.php on line 100
[30-Dec-2018 12:08:34 UTC] PHP Warning: Declaration of CustomBlockPlugin::getBlockContext() should be compatible with BlockPlugin::getBlockContext($contextId = NULL) in /home/u741823471/domains/jmedresinnovation.org/public_html/plugins/generic/customBlockManager/CustomBlockPlugin.inc.php on line 134
[30-Dec-2018 12:08:34 UTC] PHP Warning: Declaration of CustomBlockPlugin::getEnabled() should be compatible with BlockPlugin::getEnabled($contextId = NULL) in /home/u741823471/domains/jmedresinnovation.org/public_html/plugins/generic/customBlockManager/CustomBlockPlugin.inc.php on line 134
[30-Dec-2018 12:08:34 UTC] PHP Notice: Only variables should be passed by reference in /home/u741823471/domains/jmedresinnovation.org/public_html/plugins/generic/customBlockManager/CustomBlockManagerPlugin.inc.php on line 65
[30-Dec-2018 12:08:34 UTC] PHP Notice: Only variables should be passed by reference in /home/u741823471/domains/jmedresinnovation.org/public_html/plugins/generic/customBlockManager/CustomBlockManagerPlugin.inc.php on line 65
[30-Dec-2018 12:08:34 UTC] PHP Notice: Only variables should be passed by reference in /home/u741823471/domains/jmedresinnovation.org/public_html/plugins/generic/customBlockManager/CustomBlockManagerPlugin.inc.php on line 65
[30-Dec-2018 12:08:34 UTC] PHP Notice: Only variables should be passed by reference in /home/u741823471/domains/jmedresinnovation.org/public_html/plugins/generic/customBlockManager/CustomBlockManagerPlugin.inc.php on line 65
[30-Dec-2018 12:08:34 UTC] PHP Notice: Only variables should be passed by reference in /home/u741823471/domains/jmedresinnovation.org/public_html/plugins/generic/customBlockManager/CustomBlockManagerPlugin.inc.php on line 65
[30-Dec-2018 12:08:34 UTC] PHP Notice: Only variables should be passed by reference in /home/u741823471/domains/jmedresinnovation.org/public_html/plugins/generic/customBlockManager/CustomBlockManagerPlugin.inc.php on line 65
[30-Dec-2018 12:08:34 UTC] PHP Notice: Only variables should be passed by reference in /home/u741823471/domains/jmedresinnovation.org/public_html/plugins/generic/customBlockManager/CustomBlockManagerPlugin.inc.php on line 65
[30-Dec-2018 12:08:34 UTC] PHP Notice: Only variables should be passed by reference in /home/u741823471/domains/jmedresinnovation.org/public_html/plugins/generic/customBlockManager/CustomBlockManagerPlugin.inc.php on line 65
[30-Dec-2018 12:08:34 UTC] PHP Notice: Only variables should be passed by reference in /home/u741823471/domains/jmedresinnovation.org/public_html/plugins/generic/customBlockManager/CustomBlockManagerPlugin.inc.php on line 65
[30-Dec-2018 12:08:34 UTC] PHP Notice: Only variables should be passed by reference in /home/u741823471/domains/jmedresinnovation.org/public_html/plugins/generic/customBlockManager/CustomBlockManagerPlugin.inc.php on line 65
[30-Dec-2018 12:08:34 UTC] PHP Deprecated: Non-static method PKPRequest::_checkThis() should not be called statically in /home/u741823471/domains/jmedresinnovation.org/public_html/lib/pkp/classes/core/Dispatcher.inc.php on line 245
[30-Dec-2018 12:08:34 UTC] ojs2: 404 Not Found

Hi,

Yeah, I do not think I ever considered how to redirect the old url’s to the new ones when they are indexed for example by google. Of course that is important with old sites.

It will be great if thats possible. Somehow if we can redirect domain.com/path/anything to domain.com/anything.

Hi All,

(http://www.proceedings.pub)

We changed in the OJS configuration file and managed to remove index.php; however, the whole theme changed to the current design.

Please advice us with the right code that we should add to our hta access taking into consideration that we are using Hostgator shared business plan.

Many thanks and best wishes

Can you clarify exactly what you changed, what you were expecting, and what you see instead?

The link you provided currently appears to point to a vanilla OJS 3.x install.

Not sure if this is the right place, but we moved a (single) journal install to another place and did some changes. later on, we unfortunately noticed that we accidental changed the journal path. We now have links to articles with both /path1/ and /path2/ and I am looking for a code to redirect path2 to path1 so indexed urls will still be valid.

I tried with a .htaccess file, but can’t get that to work and likely don’t understand enough about how OJS redirects urls, though, since it’s a single journal install I am hoping it won’t be too difficult.

Thanks for your help!

This would be better as a new thread, though many of the concepts you read here will be used. If you have access to mod_rewrite, you can do this within your .htaccess file. Please open a new thread specific to this issue; feel free to tag me.

Thanks, created a new topic here: One journal, two paths

Dear friends,

is this still guide the definitive way to solve the website url issue for single journals? Does it apply also for OJS 3.0?

This advice applies to both 2.x and 3.x.

Dear friends,

I am amazed, because after some hours of working around I have managed to do everything: I removed the index.php part of the url and even the Journalpath.
Now I have the url I always wanted.
However, visually the site broke. All the style was broken.
I am fighting.

Hi @leonardo.mancini

Could you look at that solution?
Regards,

and you might need to modify config.inc.php as well.

Hi @drugurkocak,

many thank for this advise. I am reading the two threads and I am amazed by the amount of work.
The second thread (SOLVED: Upgrade from OJS 3.1.2.4 to OJS 3.2.1.2: problems with url api in back-office - #13 by drugurkocak), in your final post, is more clear to me, but I read that you say that that solution is not working yet on single journals installation only, which is my current case.

I have to say that before, an hour ago, I did manage to delete all the index.php/journalpath, but the style of the website was broken.
So now I have done a step backwards and I have restored the journalpath. This is my single journal site, installed in a subdirectory: https://www.ista-online.org/journal/jta

I am looking forward to delete that “jta” (which is my journalpath) away.
Many thanks for now, I will keep studying your documentation.
Best wishes,
Leonardo

Hi @leonardo.mancini

Can you modify and test that scenario on your OJS installation?

Please consider that your server configuration is also important for the result. This solution is for a Linux Apache webserver.

Sample configuration to remove index.php and journal path on Single OJS Journal

domain: https://www.cancer-research.net
journal path: jcr

PHP script execution mode : CGI wrapper (run as virtual server owner)

HTACCESS

# OJS 3.2.1.2 remove journal path

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /

# Bugfix for OJS 3.2.0-3: submissions API doesnt work with shortened URLs

RewriteCond %{SERVER_NAME} ^(www\.)?cancer-research.net

RewriteRule ^api/v1(.*)$ index.php/jcr/api/v1$1 [L,R=307]

# Rewrite URL to look cleaner
RewriteCond %{SERVER_NAME} ^(www\.)?cancer-research.net
RewriteCond %{REQUEST_URI} !/jcr/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/jcr/$1 [L]


RewriteRule ^api/v1(.*)$ index.php/index/api/v1$1 [L,R=307]


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

</IfModule>

CONFIG.INC.PHP
base_url = "https://www.cancer-research.net"
base_url[index] = https://www.cancer-research.net/index
base_url[jcr] = https://www.cancer-research.net
restful_urls = On
 
 htaccess directives for apache virtual host:

 Options +ExecCGI +FollowSymLinks +IncludesNOEXEC -Indexes +SymLinksIfOwnerMatch
  allow from all
 AllowOverride All
 Require all granted

Regards,

Update: I get success when modified and applied them.
You may check it at;
https://www.cancer-research.net
for a temporary time.
username: sysmanager
pass: 123456
You may try to change everything in the settings.
Let’s thank to @KBodarwe and @klausru again :slight_smile:
Regards,

Dear @drugurkocak,

Many thanks, I will follow this and let you know.
Do you think that I could do even if I install my OJS in a subdomain? In my case that would be: https://jta.ista-online.org.

Best wishes, many thanks,
Leonardo