RewriteRule of .htaccess not aliasing the url

ojs3

#1

Hi,

I have an OJS 3.101 instaled with 2 domains name, for example:

For the portal i have: www.myportal.com.br
For the Journal i have : www.myjournal.com.br

My .htaccess basicaly is:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{HTTP_HOST} ^myjournal.com.br$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.myjournal.com.br$ [NC]
RewriteRule ^(.*) https://www.myportal.com.br/index.php/myjournal%{REQUEST_URI} [R=301,NC]

The problem:

When i type myjournal.com.br it goes to myportal.com.br/index.php/myjournal, as expected, but i need it to keep the myjournal.com.br url at the browser…

IF i add the [P] flag at [R=301,NC,P], i got the right url at the browser (myjournal.com.br), but the site shows the myportal.com.br content…

Before i went nuts inside the .htaccess i tried the restful_urls way. And the OJS keep showing the unformated version of the page…

Is there a way that I can solve this problem inside the .htaccess?

Thks a lot

R.I.P Stan Lee


#2

Saying “i need it to keep the myjournal.com.br url at the browser” suggests that you are not wanting to redirect the browser, but rather rewrite the request.

These are two distinct operations. In the example code you provided you are redirecting the web browser with any request to myjournal.com.br, telling the browser to go to www.myportal.com.br instead.

To perform a rewrite of the request would be to have your server provide the content for one URI path via another URI path. This is want typically happens with the RESTful URLs configuration. For example, a request comes in for “/ojs/myjournal/index”, which doesn’t actually exist, so it is re-written as “/ojs/index.php/myjournal/index”, which passes parameters of “myjournal/index” to the “/ojs/index.php” script.


#3

Thanks a lot @ctgraham

When i put the restful_url = On all my css were not loaded. My page become unformated. Total caos.

If you may take a look, these are my (client’s) real sites.

the portal: acervomais.com.br --> goes to https://www.acervomais.com.br/
the journal: acervocientifico.com.br --> goes to https://www.acervomais.com.br/index.php/cientifico/

Is there a way that i can keep the acervocientifico.com.br (url) without turning the restful_url On?

Sorry to bother you


#4

The most straightforward way to manage multiple domains is by using multiple virtual hosts in your Apache configuration. If you only have access to the Apache configuration via .htaccess, you will need to setup multiple re-write rules. This can be configured with or without restful URLs.

There is a fairly extensive discussion on multiple domains here:

Do be aware, however, that this will require mastery of Apache’s mod_rewrite directives and it is one of the more complex server administration topics discussed here.