Forum Moderators: phranque

Message Too Old, No Replies

Running PHP within HTML page on FreeBSD

         

wheelie34

7:31 am on Oct 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi
Currently I use the follwing in htaccess

AddHandler server-parsed .html
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html

Now I have just got a dedicated server from a UK ISP and want to move the site over, the above code doesnt work on freebsd, does anyone know if it will run or what changes need making to the http.conf file to make it work.

Thanks

physics

9:19 pm on Oct 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Why are you using RemoveHandler? It looks to me like you added a handler for .html and then immediately removed it.
[httpd.apache.org...]

The RemoveHandler directive removes any handler associations for files with the given extensions. This allows .htaccess files in subdirectories to undo any associations inherited from parent directories or the server config files.

Try getting rid of that line.

wheelie34

7:18 am on Oct 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Physics

If I remove that line it tries to download the page rather than show it.

The page is a .htm extension and on it I have

<!--#echo var="DATE_LOCAL" -->
<?php phpinfo();?>

Now the funny thing is, if I remove the remove handler and hit refresh it shows me the ssi date etc but not php, if I hit enter to recall the url it shows the ssi but then tries to download the page.

Do you think the server httpd.conf file has something missing? to run php within html, what needs to be added?

Thanks for your help

jdMorgan

5:01 pm on Oct 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Looks to me like you've got MIME-types and handlers confused.

Look up the functions of AddHandler and AddType, and read carefully; The mime-type sent with an HTML page or the HTML output of a PHP script should be text/html, not "application/x-httpd-php" if you want the browser to render it.

Jim

wheelie34

7:24 pm on Oct 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Maybe the htaccess file is confused but it works on ensim and a n other server (not sure what system as its only a hosting account)

I have narrowed it down to apache versions, the version with the problem is 1.3 it runs fine on 2.0

jdMorgan

8:01 pm on Oct 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Again, please review the docs.

It may work on 2.0 due to a kludge in the PHP setup, but it's incorrect to set a MIME-type of application/anything on a file that you want rendered or played within the browser.

Jim