htaccess not working??

Discussions of secure PHP coding. Security in software is important, so don't be afraid to ask. And when answering: be anal. Nitpick. No security vulnerability is too small.

Moderator: General Moderators

Post Reply
ibolui
Forum Commoner
Posts: 27
Joined: Thu May 26, 2005 9:41 am

htaccess not working??

Post by ibolui »

hi, i know this question has been asked many times..and i have googled alot but i am still unable to get the desired result.

my .htacess is as below

Code: Select all

Options -Indexes
Options -ExecCGI
AddHandler cgi-script .php .php3 .php4 .phtml .pl .py .jsp .asp .htm .shtml .sh .cgi
<Files ^(*.jpeg|*.jpg|*.png|*.gif)>
order deny,allow
deny from all
</Files>
the Options -Indexes works but not the rest. because if i put a index.php with phpinfo(), i am able to view the php info.
if i remove |*.gif, i am still able to load gif files in the browser.
and if i put a text file in the directory, i am also able to load the text file.

anyone guide me what went wrong??
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: htaccess not working??

Post by Benjamin »

This is likely due to how AllowOverride is configured in the main apache configuration:

http://httpd.apache.org/docs/2.0/mod/co ... owoverride
ibolui
Forum Commoner
Posts: 27
Joined: Thu May 26, 2005 9:41 am

Re: htaccess not working??

Post by ibolui »

hmmm... actually i am testing it in my development machine. i am using windows xp with xampp installed.
how do i check the directives are allow ALL??

btw, if i intend to make the directory serves only image files, and there are subfolders, do i need to include each subfolder with the htaccess as well??

thanks :)
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: htaccess not working??

Post by josh »

Intentionally insert a defect into the .htaccess file, it should generate a 500 server error if Apache is configured to parse it. If you get no error, the issue is as Benjamin says. If you get an error then the .htaccess is being loaded but the issue is due to invalid syntax. This is called "divide & conquer"
Peter Kelly
Forum Contributor
Posts: 143
Joined: Fri Jan 14, 2011 5:33 pm
Location: England
Contact:

Re: htaccess not working??

Post by Peter Kelly »

ibolui wrote:hi, i know this question has been asked many times..and i have googled alot but i am still unable to get the desired result.

my .htacess is as below

Code: Select all

Options -Indexes
Options -ExecCGI
AddHandler cgi-script .php .php3 .php4 .phtml .pl .py .jsp .asp .htm .shtml .sh .cgi
<Files ^(*.jpeg|*.jpg|*.png|*.gif)>
order deny,allow
deny from all
</Files>
the Options -Indexes works but not the rest. because if i put a index.php with phpinfo(), i am able to view the php info.
if i remove |*.gif, i am still able to load gif files in the browser.
and if i put a text file in the directory, i am also able to load the text file.

anyone guide me what went wrong??
Hi, just an observations but can I ask how you spelt the file as it should be .htaccess thats with 2 c characters just I noticed in the first post it is spelt incorrectly this could be a one off mistake but apache doesn't process it unless its spelt correctly.
Post Reply