Site-specific route


Is there a good technique for limiting a new route to a specific site in a module? It doesn’t seem to be doable just in the module.config.php, I think.

My thought is to create the new route and then in the controller for it check for the site I want, and if it isn’t that site, return an error. Does that seem like the best way to go about it?


Joseph Anderson

You probably can do it by hardcoding in the slug for your site in a route, and having it live at the top level, outside the usual “site” route tree, but you’d need to make sure all the proper parameters are set for it like '__SITE__' => true and the right site-slug, so Omeka S’s core code knows this route is a public site route and sets things up properly.

Having it just be within the normal “site” route is simpler though, and just rejecting other sites in the controller sounds like a fine solution.

1 Like

Ok, thanks for the guidance—seems to be working out pretty well.