Svn – Is it possible for the Subversion Apache module to serve html files with an html content-type without using the svn:mime-type property

apache-2.2mod-dav-svnmod-rewritesvn

I am aware that if you set the svn:mime-type Subversion property on a .html file to text/html then when viewing the file in a browser through the Subversion module in Apache httpd it will be served with a Content-Type: text/html header, enabling the browser to render it as HTML rather than plain text.

However, I am looking for a way to do this without using the svn:mime-type property.

I'm aware that you can configure your svn client to automatically add the property – this is not what I want, as I do not want to ensure all users have these settings. I'm also aware that I could create a pre-commit hook that rejects the commit if the properties are not set, in order to force users to set the property – I might fall back to that, but I'm looking for something less intrusive.

I'm also aware that I could use a post-commit hook to add the properties automatically on the server-side. I'd rather not do that (as users then have to update immediately after their commit, and it's not trivial to write) – I'm looking for a better alternative. Perhaps something with rewrite rules in the Apache server?

Best Answer

Short answer - yes - set ModMimeUsePathInfo to on to make Apache responsible for the MIME types.

Longer answer - yes but you need to be using a relatively modern version of Subversion within your Apache server.

Normally the content is being served by the mod_dav_svn module which is interrogating the Subversion repository, therefore the mime-type would be specified by the Subversion module.

Historically this was only able to be configured using the svn:mime-type property. See this thread on the Subversion User's mailing list for an example of someone attempting to perform something similar.

Now, using the ModMimeUsePathInfo directive will tell Apache to figure out what MIME type to specify using mod_mime - see Appendix C, WebDAV and Autoversioning of the Subversion book for more info.

Specifically something like:

<Location /repos>
    DAV svn
    SVNPath /var/svn/repository
    SVNAutoversioning on

    ModMimeUsePathInfo on
</Location>