You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by webmaster <we...@StuckMic.com> on 2002/02/22 23:51:01 UTC
htaccess and mime types
Hi all,
A real newbie here with a question.
I'm using an htaccess file to protect a directory of large gifs and
sounds. Here is what i've written:
-------------------------------------------------------------
AuthUserFile /dev/null
AuthGroupFile /dev/null
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://www.myserver.com [NC]
RewriteCond %{HTTP_REFERER} !^http://myserver.com [NC]
RewriteRule /* http://www.myserver.com/error.mv [R,L]
-------------------------------------------------------------
The problem i'm having is, somebody may try to directly access my
directory looking for a file named "lookatme.gif", they get forwarded
to the error page, but the browser receives the error page and
downloads it as "lookatme.gif". Of course when the person tries to
open it they get an error message because the received file is not a
".gif" file but html text.
I'm reading my Apache bible and the section on MIME types and my
question is: Is there a way to modify the htaccess file so that
regardless of the file requested (".gif", ".wav", ".jpg", etc.) they
would receive a file recognizable as an html document or a plain text
file when clicked on?
Any help would be greatly appreciated,
Paul Williams
--
======================================
http://www.StuckMic.com/america -- The American Code
Remembering the attack on America
http://www.StuckMic.com -- MIVA Powered Aviation
and Air Traffic Control discussion and chat.
http://www.WavSounds.com -- Thousands of
funny wavs, fully searchable.
Re: htaccess and mime types
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> I'm reading my Apache bible and the section on MIME types and my
> question is: Is there a way to modify the htaccess file so that
> regardless of the file requested (".gif", ".wav", ".jpg", etc.) they
> would receive a file recognizable as an html document or a plain
> text file when clicked on?
well, I'm not sure exactly what you're after, but I run this
PerlFixupHandler on a Cobalt where I don't have the ability to really
get at the phases the way I want to (through the AddHandler directive
and so on, which is probably the most proper way to do it)...
package Custom::Unscript;
use Apache::Constants qw(OK DECLINED);
use strict;
sub handler {
my $r = shift;
my ($extension) = $r->filename =~ m!(\.[^.]+)$!;
# un-script a bunch of stuff
if ($extension eq '.pl' ||
$extension eq '.PL' ||
$extension eq '.html' ||
$extension eq '.ksh' ||
$extension eq '.ppm' ||
$extension eq '.xml' ||
$extension eq '.xls' ||
$extension eq '.rss' ) {
$r->content_type('text/plain');
$r->handler('default-handler');
return OK;
}
return DECLINED;
}
1;
Re: htaccess and mime types
Posted by Andy Lester <an...@petdance.com>.
> I'm reading my Apache bible and the section on MIME types and my
> question is: Is there a way to modify the htaccess file so that
> regardless of the file requested (".gif", ".wav", ".jpg", etc.) they
> would receive a file recognizable as an html document or a plain text
> file when clicked on?
Whyncha just have it return a 403 ?
xoxo,
Andy
--
%_=split/;/,".;;n;u;e;ot;t;her;c; ". # Andy Lester
'Perl ;@; a;a;j;m;er;y;t;p;n;d;s;o;'. # http://petdance.com
"hack";print map delete$_{$_},split//,q< andy@petdance.com >