.htaccess internal rewrite

Hello everyone,

first of all, thanks for making Omeka, we love working with it so far in our team. Now, the problem I have is that I would like to create an internal redirect from a simple URL to a search result, i.e.:


should redirect (internally) to:


How would I accomplish this? I have tried playing around with .htaccess, but without success. I managed to create a RewriteRule with an external rewrite, but whenever I remove the [R] flag I get a 404 error.

I hope this can be done. Thanks in advance for any help!

If the News page is an Omeka page, you can just create a custom navigation link in your settings.

See: /admin/appearance/edit-navigation

If it’s external and PHP-based, you can add something like this to the existing News page:

header("Location: http://mysite.com/items/browse?collection=2&sort_field=added&sort_dir=d"); 

Or, with .htaccess, something like:

Redirect 301 /news /items/browse?collection=2&sort_field=added&sort_dir=d

Thanks! That would work, but I was trying to avoid using a 301 redirect (the address shouldn’t change in the address bar for the user).

However that didn’t work using only .htaccess. But in the meantime I figured out that adding a route in /application/config/routes.ini like this will work:

news.route = "news"
news.defaults.controller = "items"
news.defaults.action = "browse"

And then in .htaccess:

RewriteCond %{QUERY_STRING} ^$
RewriteRule ^news/?$ ?collection=2&sort_field=added&sort_dir=d [L]

This will redirect /news/ to /items/browse and then append the query string if it is not present already (otherwise the pagination will break).

Now I’m asking myself if there’s a better or simpler way to do this and if this is even recommended. For example, is there a way to use only routes.ini without .htaccess?

I know that this could be accomplished using a plugin, but if possible I would like to avoid having to write one as I don’t know enough PHP…