tags:

views:

78

answers:

2

I want to send my RSS/Atom feeds with the correct Content-type header, can I do this without access to PHP or any other server-side language? The goal is for the browser to treat the file as a feed and not just a plain XML file.

A: 

If your RSS/ATOM feed has a specific extension, or is served from a specific dorectory, I suppose you could use Apache's AddType directive, so Apache would serve your RSS feeds with the right content-type :

The AddType directive maps the given filename extensions onto the specified content type. MIME-type is the MIME type to use for filenames containing extension.


Not tested, but I suppose something like this, either in your Apache's main configuration file, or in a .htaccess file, might do, for RSS feeds :

AddType application/rss+xml .rss

And, for ATOM, something like this, probably :

AddType application/atom+xml .atom
Pascal MARTIN
+5  A: 

You can tell the server to send that specific file with a specific media type.

Apache has the AddType and ForceType directive to do that:

# send all .atom files with application/atom+xml
AddType application/atom+xml .atom

# send only foo.bar as application/atom+xml
<FilesMatch ^foo\.bar$>
    ForceType application/atom+xml
</FilesMatch>

You can use <Directory>, <DirectoryMatch>, <Files>, <FilesMatch>, <Location> and <LocationMatch> sections to restrict the directives only to specific directories, files or URL paths. But be aware of the context they are allowed in. Only <Files> and <FilesMatch> can be used in a .htaccess file.

Gumbo