You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Erik Andersson <er...@cybercomgroup.com> on 2004/06/10 17:31:10 UTC

[users@httpd] Forcing files in a directory to be opened by the browser

Hi all.

Is it possible to force certain files in a directory to be opened with
the browser instead of the associated application?

I have created the following entry in my httpd.conf to allow the users
to see all the log-files in the logs-folder, but I don't want then to
open them with the associated program. I would like the files to open in
the browser so they after they opened the file can refresh the browser
to get the updated content of the log-file.

Httpd.conf:

Alias /logs/resin_logs/
/opt/app/resin/2.1.6/logs/
<Directory "/opt/app/resin/2.1.6/logs">
    Options Indexes MultiViews
    AllowOverride AuthConfig
    AuthType Basic
    AuthName "Restricted Files"
    AuthUserFile /opt/app/apache/2.0.49/passwd/passwords
    Require valid-user
    Order allow,deny
    Allow from all
</Directory>

I'm a rookie when it comes to configuring web-servers, so please forgive
me if I'm asking stupid questions.

Best Regards / Erik Andersson

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Forcing files in a directory to be opened by the browser

Posted by Tim Burden <ti...@burden.ca>.
Maybe
<Files *.log>
ForceType text/plain
</Files>

----- Original Message ----- 
From: "Erik Andersson" <er...@cybercomgroup.com>
To: <us...@httpd.apache.org>
Sent: Thursday, June 10, 2004 11:31 AM
Subject: [users@httpd] Forcing files in a directory to be opened by the
browser


Hi all.

Is it possible to force certain files in a directory to be opened with
the browser instead of the associated application?

I have created the following entry in my httpd.conf to allow the users
to see all the log-files in the logs-folder, but I don't want then to
open them with the associated program. I would like the files to open in
the browser so they after they opened the file can refresh the browser
to get the updated content of the log-file.

Httpd.conf:

Alias /logs/resin_logs/
/opt/app/resin/2.1.6/logs/
<Directory "/opt/app/resin/2.1.6/logs">
    Options Indexes MultiViews
    AllowOverride AuthConfig
    AuthType Basic
    AuthName "Restricted Files"
    AuthUserFile /opt/app/apache/2.0.49/passwd/passwords
    Require valid-user
    Order allow,deny
    Allow from all
</Directory>

I'm a rookie when it comes to configuring web-servers, so please forgive
me if I'm asking stupid questions.

Best Regards / Erik Andersson

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Forcing files in a directory to be opened by the browser

Posted by Robert Andersson <ro...@profundis.nu>.
Erik Andersson wrote:
> Is it possible to force certain files in a directory to be opened
> with the browser instead of the associated application?

Generally speaking, no. The HTTP standard does not enforce any specific
behavior in such cases; the client is free to handle them as they see fit.
However, you can try to tweak your config so that the common browsers do the
"right" thing.

The reason why your browser wants to open the file in an external
application is probably because Apache sends the Content-Type
"application/octet-stream" (ie. unknown). Setting it to "text/plain" should
cause most browsers to display the logs. See Tim Burden's post for one way
to do that (although I think he missed that your log doesn't have an
extension, so you would use the full filename).

You could also try enabling the mod_mime_magic which peaks into the file to
determine the type. It will slow down your server somewhat.

Regards,
Robert Andersson


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org