[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[SOLVED] Text files treated like html in apache 2.4



On Mon, 12 May 2014 20:28:24 -0400 (EDT), Stephen Powell wrote:
> ...
> But with Apache 2.4, it treats the text file like html and reformats
> everything, concatenating lines, eliminating blank lines, etc.  How do
> I get it to treat plain text like plain text again?

Well, the joke is on me.  The text file I was trying to view was a
Windows-style text file, with each line (except the last) ending in
a <CR><LF> combination.  But it was being served up by Apache running
on Linux.  Linux-style text files have each line (except the last)
end with only a simple <LF>.  This apparently confused Microsoft
Internet Explorer and it did not recognize it as a plain text file.
The solution was simple enough:

   sed -e 's/^V^M$//' file.txt >newfile.txt
   rm file.txt
   mv newfile.txt file.txt

Where "^V^M", of course, represents Ctrl+V and Ctrl+M in sequence,
typed at a bash prompt.  (^V is readline's way of escaping a ^M.)
Note that the $ causes a carriage return to be deleted only if it
is the last character of the line.  Embedded carriage returns, if
any, are not deleted.

Doing this, plus refreshing the browser cache with F5, did the trick.

-- 
  .''`.     Stephen Powell    
 : :'  :
 `. `'`
   `-


Reply to: