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:
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
@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/
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.
[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
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.
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.
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.
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.
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
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
Regards,
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.