Multi-domain rewrite rules problems

OJS Version: 3.3.0.13 (diciembre 26, 2022 - 08:59 )

Hello, I’m trying to configure OJS with multi-domain but I can’t configure the mod_rewrite rules correctly.

First of all, I need http to redirect to https. I have tried this for the case of “index” and “sybil”:

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

   RewriteCond %{HTTP_HOST} ^sybil-dev\.tirant\.com [NC]
   RewriteCond %{SERVER_PORT} 80
   RewriteRule ^(.*)$ https://sybil-dev.tirant.com/sybil$1 [R,L]

   RewriteCond %{HTTP_HOST} ^aepdiri-dev\.tirant\.com [NC]
   RewriteCond %{SERVER_PORT} 80
   RewriteRule ^(.*)$ https://aepdiri-dev.tirant.com/$1 [R,L]  
</IfModule>

In principle it redirects correctly.

Second, I need that when the URL https://sybil.tirant.com is written, it rewrites to https://sybil.tirant.com/sybil, which is where Sybil magazine is.
I have tried several rules, but without result.

What am I doing wrong?

config.inc.php:

base_url = "https://aepdiri-dev.tirant.com"
...
base_url[index] = https://aepdiri-dev.tirant.com/index
base_url[redi] = https://redi-dev.tirant.com/redi
base_url[reei] = https://reei-dev.tirant.com/reei
base_url[sybil] = https://sybil-dev.tirant.com/sybil
...
restful_urls = On

htaccess:

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

   RewriteCond %{HTTP_HOST} ^sybil-dev\.tirant\.com [NC]
   RewriteCond %{SERVER_PORT} 80
   RewriteRule ^(.*)$ https://sybil-dev.tirant.com/sybil$1 [R,L]

   RewriteCond %{HTTP_HOST} ^aepdiri-dev\.tirant\.com [NC]
   RewriteCond %{SERVER_PORT} 80
   RewriteRule ^(.*)$ https://aepdiri-dev.tirant.com/$1 [R,L]
</IfModule>

Hi @carlosgo

The force_ssl config.inc.php option should take care of the forcing to SSL for you. But the way we’ve dealt with that in the past at PKP PS is that we have a separate <VirtualHost> container that only listen on port 80 for requests and then send them over to the https version of the same URL. This may greatly simplify your rewrite rules in the 443 VirtualHost.

Best
Jason

Thank you. I hadn’t noticed the force_ssl option in the config.inc.php setting.

I will keep trying the rewrite from https://sybil.tirant.com to https://sybil.tirant.com/sybil

At the moment I have disabled restful_urls, to see if the redirection works. I’m just testing with one of the journals.

base_url[index] = 'https://aepdiri-dev.tirant.com/index.php/index'
base_url[redi] = 'https://redi-dev.tirant.com/index.php/redi'
base_url[reei] = 'https://reei-dev.tirant.com/index.php/reei'
base_url[sybil] = 'https://sybil-dev.tirant.com/index.php/sybil'
restful_urls = Off

I’m testing these rules in htaccess so that typing the URL https://sybil-dev.tirant.com will go to https://sybil-dev.tirant.com/index.php/sybil:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^sybil-dev\.tirant\.com
RewriteCond %{REQUEST_URI} !^/index.php/sybil.*$
RewriteRule ^(.*)$ https://sybil-dev.tirant.com/index.php/sybil$1 [R=301,L]

Correctly rewrites the URL but does not load images or styles. When entering the administration I see uninterpreted templates.