Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

What configuration is required to make Apache serve all files as text files in the browser window? For example if I have a file program.c, how can I make Apache serve it as plain text in the browser window rather than as a download?

I'm using Apache 1.3.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

You can use this to force the data type of all files, e.g. for a specific location:

<Location "/programfiles">
    ForceType text/plain
</Location>

So, no matter what's in there, even .php files, they're treated as plain text and shown to the browser instead of being download or even executed on the server side.

For more info see the mod_mime reference page for ForceType.

share|improve this answer
    
Thanks, that was what I was looking for. –  delete Nov 7 '09 at 15:53
    
+1 Good call. I added a link to the Apache reference for this. –  squillman Nov 7 '09 at 15:58

You want ALL files to go over as plain text?? Or do you have a subset of filetypes you want to send as plain text? Not sure if there's a way to set everything to go over as plain text.

For certain file types you would just add directives to your Mime.types file or local .htaccess file

AddType text/plain .c
AddType text/plain .h

etc.

share|improve this answer
    
Thanks, that wasn't exactly what I was looking for but it will be useful for reference. –  delete Nov 7 '09 at 15:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.