1

I'm using PhpStorm 2016 with php language level 5.6 and the interpeter is PHP 5(5.6.24) and xampp version 3.2.2 . I'm trying to add some php code in html page, I created a file .htaccess in the same folder where my html file located, and put AddType application/x-httpd-php5 .html .htm inside it, added <?php echo "example" ?> but it doesn't show up. I even tried <FilesMatch "\.html$"> ForceType application/x-httpd-php </FilesMatch>, AddHandler application/x-httpd-php5 .html .htm and AddType application/x-httpd-php .html .htm but nothing work, don't know what eles to do.

Hope you can help me with any idea.

Thank you.

zb22
  • 3,126
  • 3
  • 19
  • 34
  • You may need to edit the Apache config file, and check if `AllowOverride` is set to none. If AllowOverrideList is set to None, .htaccess files are completely ignored. See https://httpd.apache.org/docs/2.4/mod/core.html#allowoverride – Duane Lortie Jun 19 '17 at 20:02
  • It is none, so for what should I change it to instead? – zb22 Jun 19 '17 at 20:17
  • To allow only the ForceType directive it would be "AllowOverride FileInfo" or if you want all entries in your .htaccess to be honored, then "AllowOverride All" – Duane Lortie Jun 19 '17 at 20:29

2 Answers2

1

You may need to edit the Apache config file, and check if AllowOverride is set to none. If AllowOverride is set to None, .htaccess files are completely ignored.

See httpd.apache.org/docs/2.4/mod/core.html#allowoverride

To allow only the ForceType directive it would be

AllowOverride FileInfo

or if you want all entries in your .htaccess to be honored, then

AllowOverride All
Duane Lortie
  • 1,285
  • 1
  • 12
  • 16
  • I don't have AllowOverrideList in apache config file at all, I tried to change AllowOverride from none to All, but it didn't work – zb22 Jun 19 '17 at 20:40
0

In order to get xampp to interpret the file as PHP, you will need to set the Apache Server web-root to the base of your project (where the html files are) and access the webserver via the server (HTTP in a web-browser).

It sounds like you're trying to access the file directly with the browser (skipping the PHP processor).

circusdei
  • 1,967
  • 12
  • 28