Serving files from subdomain

I’m currently in the process of configuring or Apache2 server to serve our static resources from a subdomain.

What would be the best approach for changing all requests to files, ie “http://www.example.com/files/fullsize/image.jpg” into “http://static.example.com/files/fullsize/image.jpg”?

I tried setting up a rewrite rule to redirect all request under /files to the subdomain but that also leads to isses with redirect chains. Would it work to substitute file paths directly in PHP and change the domain part of the URL? If so, where would be the best place to do this in Omeka?

You can set the base URL that files (everything under the files directory by default) will be served from in application/config/config.ini

You’d add a line like this:

storage.adapterOptions.webDir = "http://static.example.com/files"

You can also change where files are saved to a different path in the config file, by setting the localDir adapter option in the same way. This may be useful if you want to just move the files completely out of the main DocumentRoot.

1 Like

Thank you! Splendid as ever :slight_smile: