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

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.
Posts: 36
Joined: Fri Jan 12, 2007 6:17 am

mod_rewrite question

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

Hallo, I'm going crazy with this case:

There is an Institution:

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 to create a second level domain and point it to the server wich hosts:

Now the Journal address is allowed in the InterNet, but I have to point it to the right address: i.e.

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
base_url[index] =
base_url[Journal] =

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 ( has to show journals with second level domains ( ,, http://www.journal3... etc etc)

1) Asked to the Admin of to create a second-level domain for each journal and point it to the OJS server, so at the end of this step: -- points to--> -- points to-->

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: -- points to--> -- points to-->
... and so on ...

So it works, there is just a problem:
the container ( 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="" 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: "" ?


Posts: 10015
Joined: Wed Aug 10, 2005 12:56 pm

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

Return to “OJS Technical Support”

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest