You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Bo Berglund <bo...@gmail.com> on 2013/05/11 10:58:49 UTC

[users@httpd] File renders differently when opened through Apache or direct, why?

I have a PHP logging script, which produces a file on the server in a
logging directory. In order to make the file easier to read through a
browser I have made the PHP script create each log line as a table row
in a table. I let the script write the file header when the logfile is
created as follows:
<html>
<body>
<table border="1"><tr>
<th align="left">Timestamp</th>
<th align="left">Username</th>
<th align="left">IP address</th>
<th align="left">hostname</th>
<th align="left">Page accessed</th>
<th align="left">Referring page</th>
<th align="left">Servername</th></tr>

Then for each access I append one line with info like the following
example from my test server (it is actually on a single line, but for
easier reading here I have cut it into lines for each column in the
table):

<tr><td>2013-05-11 10:40:14</td>
<td>Unknown User</td>
<td>10.0.0.159</td>
<td>AURIGA</td>
<td>currentpage</td>
<td>sourcepage</td>
<td>servername</td></tr>

Now I wanted to look at the logfile via my webserver so I entered the
local URL (<myservername><sitename>/logs/testpage2013-05.log) into
FireFox and what was shown was the above *source* text rather than the
expected table!
But if I open the exact same file directly in FireFox, bypassing
Apache, then the table displays as intended!
Why is this happening?

I know that the file is open ended such that it lacks the closing
</table></body></html> tags but that seems not to be a problem when
viewing the file as a file:// URL in FireFox, so why does it happen
through Apache?


-- 
Bo Berglund
Developer in Sweden


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


[users@httpd] Re: File renders differently when opened through Apache or direct, why?

Posted by Bo Berglund <bo...@gmail.com>.
On Sat, 11 May 2013 12:45:53 +0100, Pete Houston
<ph...@openstrike.co.uk> wrote:

>On Sat, May 11, 2013 at 01:34:47PM +0200, Bo Berglund wrote:
>> Since the data being transferred to FireFox looks exactly like what is
>> being used when I open the file directly in FireFox, why does FireFox
>> not display it in the same way?
>
>When you open the file directly from the filesystem, there is no HTTP
>header. When accessing the file over HTTP there is a header and it will
>specify the MIME type, which is set by Apache. This is what mod_mime
>does.
>
>http://httpd.apache.org/docs/2.4/mod/mod_mime.html
>
Well,
I made a PHP wrapper around the logfile where I include the logfile
and then also echo the endingtags of thefile.
This worked fine on my local Apache.


-- 
Bo Berglund
Developer in Sweden


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Re: File renders differently when opened through Apache or direct, why?

Posted by Pete Houston <ph...@openstrike.co.uk>.
On Sat, May 11, 2013 at 01:34:47PM +0200, Bo Berglund wrote:
> Since the data being transferred to FireFox looks exactly like what is
> being used when I open the file directly in FireFox, why does FireFox
> not display it in the same way?

When you open the file directly from the filesystem, there is no HTTP
header. When accessing the file over HTTP there is a header and it will
specify the MIME type, which is set by Apache. This is what mod_mime
does.

http://httpd.apache.org/docs/2.4/mod/mod_mime.html

HTH,

Pete
-- 
Openstrike - improving business through open source
http://www.openstrike.co.uk/ or call 01722 770036 / 07092 020107

[users@httpd] Re: File renders differently when opened through Apache or direct, why?

Posted by Bo Berglund <bo...@gmail.com>.
On Sat, 11 May 2013 11:18:12 +0200, David Ecker
<da...@ecker-software.de> wrote:

>See http://httpd.apache.org/docs/current/mod/mod_mime.html
>
>You are propably using a wrong mime type which is set by apache based on 
>the file extension.
>
>bye
>David
>
Since the data being transferred to FireFox looks exactly like what is
being used when I open the file directly in FireFox, why does FireFox
not display it in the same way?

Maybe this is not an Apache problem but a FireFox one?


-- 
Bo Berglund
Developer in Sweden


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] File renders differently when opened through Apache or direct, why?

Posted by David Ecker <da...@ecker-software.de>.
See http://httpd.apache.org/docs/current/mod/mod_mime.html

You are propably using a wrong mime type which is set by apache based on 
the file extension.

bye
David

Am 11.05.2013 10:58, schrieb Bo Berglund:
> I have a PHP logging script, which produces a file on the server in a
> logging directory. In order to make the file easier to read through a
> browser I have made the PHP script create each log line as a table row
> in a table. I let the script write the file header when the logfile is
> created as follows:
> <html>
> <body>
> <table border="1"><tr>
> <th align="left">Timestamp</th>
> <th align="left">Username</th>
> <th align="left">IP address</th>
> <th align="left">hostname</th>
> <th align="left">Page accessed</th>
> <th align="left">Referring page</th>
> <th align="left">Servername</th></tr>
>
> Then for each access I append one line with info like the following
> example from my test server (it is actually on a single line, but for
> easier reading here I have cut it into lines for each column in the
> table):
>
> <tr><td>2013-05-11 10:40:14</td>
> <td>Unknown User</td>
> <td>10.0.0.159</td>
> <td>AURIGA</td>
> <td>currentpage</td>
> <td>sourcepage</td>
> <td>servername</td></tr>
>
> Now I wanted to look at the logfile via my webserver so I entered the
> local URL (<myservername><sitename>/logs/testpage2013-05.log) into
> FireFox and what was shown was the above *source* text rather than the
> expected table!
> But if I open the exact same file directly in FireFox, bypassing
> Apache, then the table displays as intended!
> Why is this happening?
>
> I know that the file is open ended such that it lacks the closing
> </table></body></html> tags but that seems not to be a problem when
> viewing the file as a file:// URL in FireFox, so why does it happen
> through Apache?
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org