Routing Visitors from Semi-Root Directory

One thing I’m noticing on many Omeka S instances, because I’m nosy like that, is that the /s/ directory rarely if ever reroutes visitors to the main instance/Site page. Is there no built-in way to take care of that? I haven’t found it, if there is.

If you select a site from the default site option in Settings, that should redirect from your /s url.

Let us know if that does not work for you as expected

Tx, @mebrett, but alas, it does not change the behavior.

On, I’ve set the default site to be (which bounces to the default page at, but going to leaves the visitor unceremoniously on that page with a 404 or 404-like message. From that initial root (, the visitor is indeed routed to the default site, but not from what I’m calling the semi-root, the /s/ directory.

We don’t route the “semi-root” anywhere. Just having it redirect to the “true” root might be the simplest method of fixing the “hole” here.

Took me a while, but I think I’ve got it, and I’m hoping I’m just here for a double-check.

Partly for building the community, I’ll note that I first looked at forum comments on the matter in threads discussing customizing the home page and custom themes, and also at what seemed to be the appropriate Zend doco.

At first I thought it was a template issue (how I got to the wrong Zend doco), but it became clear that I’m just green with Omeka S and it’s actually a router configuration question. What seems to be working for me is an insertion into local.config.php of

    'router' => [
        'routes' => [
            'semiroot' => [
                'type' => \Zend\Router\Http\Regex::class,
                'options' => [
                    'regex' => '/s/?',
                    'spec' => '/s',
                    'defaults' => [
                        '__NAMESPACE__' => 'Omeka\Controller',
                        'controller' => 'Index',
                        'action' => 'index',

So now and both route to the default index page, which in turn goes to a Site set as the default. Is this doing things the Omeka way, or is there something more Omekan that could be done?

(Ironically, instead of using ‘redirect’ in my OP, I used ‘route’, which should have gotten me to the doco sooner.)

Omeka S always strips trailing slashes so the /? shouldn’t be necessary.

The only “issue” here, or rather, thing we’d do differently if implementing this in the core, is that we try to handle more things in Omeka S via redirects vs. multiple routes that go to the same place (and therefore multiple URLs that end up persistent in the URL bar).

On the other hand, it’s somewhat more annoying to write this in a way that issues a redirect. There’s nothing “wrong” with what you’ve done, and in your case of a site set as default, you’re getting a redirect anyway.

Ah, so I can use the Literal class instead, then?

As for redirect v. route, I’m still learning, so doing it the annoying redirect way is fine. I’m stumped, though, on where to read up on redirects. Can you point me in the right direction? Would this mean creating a page, or working with IndexController somehow, or something else?

Redirecting is something that would be done in a controller, so you’d route to a controller action that would perform the redirect.

That’s what’s already happening if you have a default site configured, since the index action just redirects to the default site’s URL in that case.

1 Like