OJS3 rewriting subdomains for journals, problem with admin panel journal drop down

Hi,

I have exprimented with mod_rewrite and OJS3 and now have working config for journal subdomains.

The only problem I have discovered is with the journal drop down menu in the top left corner.

If I go to the admin panel of a journal that uses a subdomain, the links in the menu are broken because they link to:
http://currentjournalname.domain.fi/linkedjournalname/submissions

Hopefully this gets fixed, because subdomains seem to work very well otherwise.

Hi @ajnyga,

Can you describe your rewriting setup a little?

Have you set up mappings between the journals and their rewritten URLs in config.inc.php's base_url[...] directives?

Regards,
Alec Smecher
Public Knowledge Project Team

Ah, yes. So I have in config.inc.php

base_url = “http://mydomain.fi
restful_urls = On
base_url[index] = http://mydomain.fi/index
base_url[journal1] = http://juornal1.mydomain.fi

Wildcards are enabled.

In htaccess I remove the index.php part and rewrite subdomains.

So with two example journals with this setup I would have
http://juornal1.mydomain.fi
http://mydomain.fi/journal2 (this works since no base_url is defined for journal2)

Now, if I open the admin panel from journal1, the links that I get in the journals drop down are:
http://juornal1.mydomain.fi/submissions (this works)
http://juornal1.mydomain.fi/journal2/submissions (this of course does not, because the subdomain remains as base)

In journal2 the same drop down is:
http://juornal1.mydomain.fi/submissions (this works)
http://mydomain.fi/journal2/submissions (this works)

Basically everything else seems to work. The only problem seems to be with that drop down.

Edit. I understand that the changes should apply here:

Line 197: $contextUrl = $dispatcher->url($request, ROUTE_PAGE, $workingContext->getPath(), ‘submissions’);

However, I am not sure which variable would work here.

Hi @ajnyga,

Why not specify a base_url for journal2? I’ve never worked in a situation where a mixture of specified and non-specified journals is used; perhaps that’s the issue.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

Thanks. I am going to suggest subdomains for all journals, but it might happen that not all journals want to use them. If they do, then this is of course not a problem anymore. However, since this dropdown seems to be basically the only problem here it would be nice to find out a working solution.

I am also thinking that would this same problem appear if one of the journals wanted a domain of their own? Would that lead to:

base_url = “http://mydomain.fi
restful_urls = On
base_url[index] = http://mydomain.fi/index
base_url[journal1] = http://otherdomain.fi

Journal1 dropdown:
http://otherdomain.fi/submissions (this works)
http://otherdomain.fi/journal2/submissions (this of course does not, because the other domain remains as base, or does it?)

In journal2:
http://otherdomain.fi/submissions (this works)
http://mydomain.fi/journal2/submissions (this works)

Or is this only subdomain related?

Hi @ajnyga,

Try specifying something like…

base_url[journal2] = http://mydomain.fi/journal2

Even though you don’t have a subdomain for journal2, it’ll probably still need a base_url[...] entry to keep things consistent.

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

Thank you, that does solve it.

Another solution I found is to edit PKProuter

From line 482 onwards:

    // Generate the base url
    if (!empty($overriddenBaseUrl)) {
        $baseUrl = $overriddenBaseUrl;
        // Throw the overridden context(s) away
        while ($overriddenContextCount>0) {
            array_shift($context);
            $overriddenContextCount--;
        }
        
        
    } else {
        
        $configBaseUrl = parse_url(Config::getVar('general', 'base_url'), PHP_URL_HOST);    
        $baseUrl = $this->getIndexUrl($request);
    
        if ($configBaseUrl != parse_url($baseUrl, PHP_URL_HOST)){
            $baseUrl = $request->getProtocol() . '://' . $configBaseUrl;                
        }
        
    }

But I do not have the expertise to evaluate whether this would have some negative side effects. The advantage here is however, that if you do need a custom domain for just one journal (which could be quite common case?), then you do not have to define base_url’s for all journals in your installation by hand.

I also noted that there is a hook in PKPRouter.inc.php::getIndexUrl() which maybe could be used to solve this as well using a plugin, but I did not have the time to think that through yet.

1 Like

Hi @ajnyga,

I think it’s best to just specify all journals in base_url[...] settings in the configuration file; the downside (potentially a few extra configuration lines) is minimal compared to maintaining a modification to the router code.

Regards,
Alec Smecher
Public Knowledge Project Team

Thanks, I guess it is and although we have around 45 journals this is of course manageable for us. I still think that this is a lot of work for a site where only one journals wants to have their own domain - that is if the same problem occurs in those cases as well.

1 Like