1

I have a little piece of php code in an html file but when i browse to the file it displays some part of the code instead of executing. below is the code

<?php
session_start();
if (!$_SESSION["valid_user"])
  {
   // User not logged in, redirect to login page
    Header('Location: login.html?returnurl=' . urlencode($_SERVER['REQUEST_URI']));
   }
  echo "<p><a href=\"logout.html\">logout " . $_SESSION["valid_user"] . "</a></p>";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

here is the content of .htaccess file

`AddHandler application/x-httpd-php .html .htm`    

php version: 5.4.4 server: apache

It would be really helpful if someone can help

2 Answers 2

1

Replace the Addhandler directive with this:

AddHandler php5-script .php .html
Sign up to request clarification or add additional context in comments.

Comments

0

In my case (OS X Yosemite 10.10 running php5 and apache), When I created a .htaccess with any AddHandler, apache would throw a 500 misconfiguration error.

However, I did find that modifying my /etc/apache2/other/php5.conf worked perfectly.

Before:  AddType application/x-httpd-php .php
After:   AddType application/x-httpd-php .php .html .htm

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.