Problem to enter web with or without "www" in OJS 3.3.0-11

Problem entering the web with or without “www” in OJS 3.3.0-11

The URL of my OJS installation only allows viewing of the journal content when “www” is not included in the URL

https://rduss.cl (works perfect)

But when I add “www” https://www.rduss.cl it gives an error message: 400 Bad Request

The digital certificate (SSL) is correct and includes the domain rduss.cl with and without “www”.

In other journal urls with previous OJS versions that we have (3.3.0-8, 3.3.0-7) everything is perfect (it allows using URLs with and without “www” but with version 3.3.0-11 the problem appears.

As a workaround edit the OJS system configuration file (config.inc.php) by adding “www” in allowed_hosts:

; allowed_hosts = ‘[“myjournal.tld”, “anotherjournal.tld”, “mylibrary.tld”]’
allowed_hosts = “["www.rduss.cl"]”

But now it allows me to enter the magazine only with
https://www.rduss.cl
When trying to enter with https://rduss.cl the error appears: 400 Bad Request

Is there a way for OJS 3.3.0-11 that will allow me to access the OJS website with or without “www”?

What is the cause of this error?

I appreciate any help

Hi!..

I fixed the problem by adding “www.rduss.cl” in allowed_host in line 96 of the file config.inc.php

; allowed_hosts = ‘[“myjournal.tld”, “anotherjournal.tld”, “mylibrary.tld”]’
allowed_hosts = “["rduss.cl", "www.rduss.cl"]”

Is this correct way to solve the problem to access the OJS site with and without “www”?

Yes, this is correct. You need to list all domains. But to enclose the array you should use single quotes.

1 Like

It’s okay. thank you very much for your help!

I followed your advice “use single quotes”:

allowed_hosts = ‘[“rduss.cl”, “www.rduss.cl”]’

Thanks @mpbraendle !