You are viewing the PKP Support Forum | PKP Home Wiki

mod_rewrite question

Are you responsible for making OJS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
The Public Knowledge Project Support Forum is moving to http://forum.pkp.sfu.ca

This forum will be maintained permanently as an archived historical resource, but all new questions should be added to the new forum. Questions will no longer be monitored on this old forum after March 30, 2015.

mod_rewrite question

Postby nelson » Wed May 16, 2007 1:43 pm

Hallo, I'm going crazy with this case:

There is an Institution: http://www.institution.org

It offers a e-journals service between OJS:


So each journal has this link:


So they asked to transform this in this other:


SO, first of all, I asked to the admin of http://www.institution.org to create a second level domain www.Journal.institution.org and point it to the server wich hosts: http://www.ojs.institution.org

Now the Journal address is allowed in the InterNet, but I have to point it to the right address: i.e. http://www.ojs.institution.org/index.php/Journal

I tried Virtual Servers, but each Journal has not an its own directory, and i cannot point the Virtual Server directives to and http:// path, but it has to point at a real filesystem resource.

So I'm trying with mod_rewrite.

I uncommented the lines in conf.inc.php:
base_url[index] = http://www.ojs.institution.org/index.php/index
base_url[Journal] = http://www.Journal.institution.org

But now I don't know how to write the Rules to rewrite them.

Can anyone help me?
Posts: 36
Joined: Fri Jan 12, 2007 6:17 am

Postby nelson » Fri May 18, 2007 4:11 am

Posts: 36
Joined: Fri Jan 12, 2007 6:17 am

[SOLVED at 50%] a difficult mod_rewrite

Postby nelson » Sun Jul 01, 2007 5:18 pm

i'm going to solve my troubles, just still need a small help again:

a second level domain OJS dedicated server (http://www.ojs.institution.org) has to show journals with second level domains (http://www.journal1.institution.org , http://www.journal2.institution.org, http://www.journal3... etc etc)

1) Asked to the Admin of http://www.institution.org to create a second-level domain for each journal and point it to the OJS server, so at the end of this step:
http://www.journal1.institution.org -- points to-->www.ojs.institution.org
http://www.journal2.institution.org -- points to-->www.ojs.institution.org

2) After a lot of queries on dedicated forum I saw the light with those mod_rewrite strings:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)\.institution\.org$
RewriteCond %{HTTP_HOST} !^www\.ojs\.institution\.org$
RewriteRule .* /index.php/%1/$1 [QSA,L]

And now:
http://www.journal1.institution.org -- points to-->www.ojs.institution.org/index.php/journal1
http://www.journal2.institution.org -- points to-->www.ojs.institution.org/index.php/journal2
... and so on ...

So it works, there is just a problem:
the container (http://www.ojs.institution.org) works fine, but in the journals: links, css, images are ALL BROKEN :cry:

If I look at rendered html, a css link looks like this:

Code: Select all
<link rel="stylesheet" href="http://www.journal.institution.org/styles/common.css" type="text/css" />

So the problem is that links work only in this 2 ways:
---only relative to real server http path:
Code: Select all

and not the rewrote one

---only absolute on filesystem:
Code: Select all

(but this is a problem with variables like $cssUrl)

So the next step is:

a) make work the rewote links


b) change OJS setting to obtain always absolute paths

The second solution seems to be more handle.

So my question is:
How can I hack the $baseUrl and the $cssUrl variables modifying statically the first part of URL to: "www.ojs.intitution.org" ?

Posts: 36
Joined: Fri Jan 12, 2007 6:17 am

Postby asmecher » Mon Jul 02, 2007 12:45 pm

Hi Alfredo,

I don't have enough experience with mod_rewrite to give you a specific fix, but you should be able to get your static content (e.g. CSS) working with a mod_rewrite rule that supercedes your existing rules for cases where the index.php script is not specified.

Alec Smecher
Public Knowledge Project Team
Don't miss the First International PKP Scholarly Publishing Conference
July 11 - 13, 2007, Vancouver, BC, Canada
Posts: 10015
Joined: Wed Aug 10, 2005 12:56 pm

Return to OJS Technical Support

Who is online

Users browsing this forum: Bing [Bot] and 3 guests