Issues with .htaccess file

Hi, my htacess. file is below, I don’t know what happened, but when I enter the main domain, I return Error 500, I should go to journalwebsite.com/ojs to go for the journal to load.

##
# @package    Joomla
# @copyright  Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved.
# @license    GNU General Public License version 2 or later; see LICENSE.txt
##

##
# READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE!
#
# The line just below this section: 'Options +FollowSymLinks' may cause problems
# with some server configurations.  It is required for use of mod_rewrite, but may already
# be set by your server administrator in a way that dissallows changing it in
# your .htaccess file.  If using it causes your server to error out, comment it out (add # to
# beginning of line), reload your site in your browser and test your sef url's.  If they work,
# it has been set by your server administrator and you do not need it set here.
##

## Can be commented out if causes errors, see notes above.
Options +FollowSymLinks

## Mod_rewrite in use.

RewriteEngine On

## Begin - Rewrite rules to block out some common exploits.
# If you experience problems on your site block out the operations listed below
# This attempts to block the most common type of exploit `attempts` to Joomla!
#
# Block out any script trying to base64_encode data within the URL.
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
# Block out any script that includes a <script> tag in URL.
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL.
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL.
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Return 403 Forbidden header and show the content of the root homepage
RewriteRule .* index.php [F]
#
## End - Rewrite rules to block out some common exploits.

## Begin - Custom redirects
#
# If you need to redirect some pages, or set a canonical non-www to
# www redirect (or vice versa), place that code here. Ensure those
# redirects use the correct RewriteRule syntax and the [R=301,L] flags.
#
## End - Custom redirects

##
# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root).
##

# RewriteBase /

## Begin - Joomla! core SEF Section.
#
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
RewriteCond %{REQUEST_URI} !^/index\.php
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* index.php [L]
#
php_value session.gc_maxlifetime 10800
php_value max_input_time         10800
php_value max_execution_time     10800
php_value upload_max_filesize    110M
php_value post_max_size          120M

## End - Joomla! core SEF Section.

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php72” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php72 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php7_module>

</IfModule>
<IfModule lsapi_module>

</IfModule>
END cPanel-generated php ini directives, do not edit
RewriteEngine on
RewriteCond %{THE_REQUEST} ^GET\ /ojs/
# RewriteCond %{HTTP_HOST} ^(www\.)?journalofcasereport.com$
# RewriteRule ^ojs/(.*) /$1 [L,R=301]
# RewriteCond %{HTTP_HOST} ^(www\.)?journalofcasereport.com$
# RewriteRule !^ojs/ ojs/%{REQUEST_URI} [L]
RewriteCond %{HTTP_HOST} ^journalofcasereport.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.journalofcasereport.com$
RewriteCond %{REQUEST_URI} !ojs\/
RewriteRule (.*) /ojs/$1 [L]

Could someone please help me?

Hi @sina,

I moved your post from the old thread here: Single journal url .htaccess configuration - #31 to a new post here. that was an older thread, so it is best to start a new one.

For the 500 errors, could you please have a look in your PHP error log and report on errors from there?

Could you also indicate the version of OJS you’re using (e.g. 3.3.0-13), in the future, please include this in your posts.

-Roger
PKP Team

1 Like

Hi, thanks for the reply.

Previously Joomla was installed, so I think that’s why there are some Joomla tags on the htaccess file. It is no longer being used.

OJS version: 3.3.0.3

And currently my OJS is in a subfolder /ojs, which I preferably want to relocate it to the root (and not sure if just moving the files is enough).

The website is hosted on a shared server, and unfortunately, I don’t know where to find PHP errors.Here is the error_log:

[14-Mar-2021 05:19:04 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function PKP\Services\json_decode() in /home/denqgtqu/public_html/ojs/lib/pkp/classes/services/PKPSchemaService.inc.php:56
Stack trace:
#0 /home/denqgtqu/public_html/ojs/lib/pkp/classes/site/SiteDAO.inc.php(62): PKP\Services\PKPSchemaService->get('site')
#1 /home/denqgtqu/public_html/ojs/lib/pkp/classes/site/SiteDAO.inc.php(42): SiteDAO->_fromRow(Array)
#2 /home/denqgtqu/public_html/ojs/lib/pkp/classes/core/PKPRequest.inc.php(490): SiteDAO->getSite()
#3 /home/denqgtqu/public_html/ojs/classes/i18n/AppLocale.inc.php(78): PKPRequest->getSite()
#4 /home/denqgtqu/public_html/ojs/lib/pkp/classes/i18n/PKPLocale.inc.php(140): AppLocale::getLocale()
#5 /home/denqgtqu/public_html/ojs/lib/pkp/classes/core/Dispatcher.inc.php(131): PKPLocale::initialize(Object(Request))
#6 /home/denqgtqu/public_html/ojs/lib/pkp/classes/core/PKPApplication.inc.php(281): Dispatcher->dispatch(Object(Request))
#7 /home/denqgtqu/public_html/ojs/index.php(68): PKPApplication->execute()
#8 {main}
  thrown in /home/denqgtqu/public_html/ojs/lib/pkp/classes/services/PKPSchemaService.inc.php on line 56

Please help me.

NB. There are two .htaccess files, one in the root and one in the /ojs subfolder. I don’t know which one to edit.

Hi @sina,

With OJS, we recommend having the .htaccess file in the web root directory: https://docs.pkp.sfu.ca/admin-guide/en/configure#pretty-urls

As for the error log messages, I’m not sure about those, but I’ll see if another team member can weigh in (you can also try searching for those error messages here on the forum as well to see if they apply to your situation)

-Roger
PKP Team