-3

I am serving a non-HTML text file though Apache (2.2.22) on linux.

If I have a file like this:

Blah Blah
Blah

BLAH BLAH

...the empty (3rd) line get removed when it is served. If I put it inside a <pre> tag, like this:

<pre>
Blah Blah
Blah

BLAH BLAH
</pre>

...then it gets served correctly, with the empty line being NOT removed, as I would expect.

Is there any reason I am missing for this behavior, and any way to prevent the blank line from being removed without breaking too many things?

2 Answers 2

3

The blank line is being removed because the file is being served as HTML instead of plain text. To fix this, if your text file has a distinct file extension, then set that extension to text/plain in your apache config dir mime.conf file.

2

Are you sure the blank like is being REMOVED? I bet you real currency that it isn't, and if you use your browser's "View Page Source" option (or retrieve the file with wget and look at it in a text editor) the blank line will be there.

Your browser, absent more specific instructions is not rendering the blank line, because it defaults to treating everything as HTML. That's not a server problem though.

2
  • It is actually being REMOVED, yes. I am using curl. Mar 27, 2014 at 18:09
  • @St0rM Wow - I've literally never seen Apache do that. Do you have some "optimization" or "acceleration" modules in your configuration? (Also I owe you real currency - would you like a rupee or a ruble? :)
    – voretaq7
    Mar 27, 2014 at 18:50

Not the answer you're looking for? Browse other questions tagged .