How do block a particular file extension ?

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

How do block a particular file extension ?

Post by anjanesh »

How do block a particular file extension ?
If I have a files names with extension .fun which contain various functions then what do I have to do so that when someone enters xxx.fun it'll not appear ?
Other than in localhost, how'll I do in my host ?
Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

store them as .php, do not output any data in the files.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Thats true but I wanted to differentiate b/w php files and my include files so that it'll be easier for me for oranization. In IIS6 all file extensions except html,htm,asp,aspx etc are blocked unless we add them as we do for php. But hows that done for Apache and esp on a host ?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

.func.php maybe?
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

I've already made a site with lots of .fun and lots of .php pages calling .fun files. Plus there are some .include files which do output. Changing all those extensions and all the files calling those include files is tedious. Anyway to stop .fun from loading as in IIS6/5.1. Since Im using IIS5.1 which doesnt allow you to type in just any extension I got used to it.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

then add types that are those file extensions.. make them php parsed files.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

How abt .inc files ? I just tested one inc file and Apache seems to be parsing it as php as the php code of the inc file didnt show up - the output did. Is it standard ?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

if they are php parsed files, php will parse them, so yes.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Strange.

Code: Select all

<?php
$a=1;
$b=2;
$c=$a+$b;
echo $c;
?>
If its named test.php.inc it outputs 3.
If its named test.inc it outputs the entire code rendered as a text file.
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

apache will only parse files with .php (or php3?) by default. There are various means you can use to cblock other files either by attempting to parse them or refusing to serve them. IF you look through your httpd.conf file, there should be some comments in there explaining what you need to do.
Post Reply