Forum Moderators: coopster

Message Too Old, No Replies

htaccess failure

         

chilppp

3:38 pm on Oct 16, 2006 (gmt 0)

10+ Year Member



this looks weird. i'm trying for apache to parse php code in .html file; my .htaccess looks as follows:

RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html

Only these 2 lines of code. I have placed this .htaccess in the Sites folder (OS X).

Below is the test.html which is also in the Sites folder.

<?php
echo "text";
?>

The error is my browser isn't displaying anything. Do you guys know where have I done wrong? I have chomed the .htaccess to 644. Do I need to tweak the httpd.config?

physics

5:49 pm on Oct 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Does your apache server config allow you to use AddType in .htaccess?
The OS X default is very restrictive, look in
/private/etc/httpd/httpd.conf
And you'll see:

<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

Scroll down a bit and you'll see a section commented out like:

#<Directory /Users/*/Sites>

To open up all the users Sites dirs to .htaccess control do:

<Directory /Users/*/Sites>
AllowOverride All
</Directory>

Then restart or on the command line do: sudo apachectl restart.

chilppp

1:43 am on Oct 17, 2006 (gmt 0)

10+ Year Member



I figured this out by another round of googling.

The villian is actually the user config file.

[edited by: jatar_k at 5:38 am (utc) on Oct. 17, 2006]
[edit reason] no urls thanks [/edit]

eelixduppy

1:50 am on Oct 17, 2006 (gmt 0)



Glad you found the answer, chilppp. By the way, Welcome to WebmasterWorld! ;)

physics

4:12 am on Oct 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for finding that chillip. For the record one has to do what I said above and then also do:

cd users
sudo pico you.conf
<Directory "/Users/you/Sites/">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>

You can also do AllowOverride AuthConfig apparently but if you're administering the server for yourself you might as well let yourself override whatever you want in .htaccess.

You can also just delete the you.conf file if you'd rather not have to edit both files in the future (tested this and it seemed to work ok).