...

View Full Version : Serve Different File Extensions



mark87
01-05-2006, 07:47 PM
I've seen some sites (can't find an example at the moment) where for instance a .txt file is displayed as a html page.

How do they do that? Is it something with Apache?

missing-score
01-05-2006, 08:14 PM
Yup, either set in the main Apache httpd.conf or more likley in .htaccess, eg:



AddType text/html .txt
AddType application/x-httpd-php .magic .cool


Makes .txt files act as HTML, and .magic and .cool files act as PHP.

oracleguy
01-05-2006, 08:15 PM
It is basically just changing what encoding the server says a certain file is when it serves it up. You can do it with Apache and IIS. Though doing such a thing isn't necessarily a recommended idea since it would just add a layer of ambiguity to the site if someone else needed to work on it.

missing-score
01-05-2006, 08:18 PM
It is basically just changing what encoding the server says a certain file is when it serves it up. You can do it with Apache and IIS. Though doing such a thing isn't necessarily a recommended idea since it would just add a layer of ambiguity to the site if someone else needed to work on it.
Didn't realise you could do it with IIS (but then again, ive never touched IIS).

Alot of sites use it to hide the server technology they are using, for example make all .html pages parse as PHP or ASP, but I agree, it can add a bit of confusion if anyone else ever has to edit it.

oracleguy
01-05-2006, 08:20 PM
Didn't realise you could do it with IIS (but then again, ive never touched IIS).

Well you can't use your .htaccess method on IIS to do it but it certainly can be re-configured through the MMC to do the exact same thing.

missing-score
01-05-2006, 08:21 PM
Well you can't use your .htaccess method on IIS to do it but it certainly can be re-configured through the MMC to do the exact same thing.
Ahh right, sorry, I guessed you could do something like it on IIS but I thought you meant it was exactly the same :p

mark87
01-05-2006, 08:31 PM
Ah thanks, I thought it would be an Apache thing but couldn't find anything related to it from searching! Ooh, now I can have cool file extensions! :)

mark87
01-06-2006, 05:20 PM
Hmm, this works for the .JPG but not the .XHTML ? (I was just playing about with it ! )

AddType application/xhtml+xml .xhtml .jpg



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum