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.

3
  • 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 httpd.apache.org/docs/2.4/mod/core.html#allowoverride Commented Jun 19, 2017 at 20:02
  • It is none, so for what should I change it to instead? Commented Jun 19, 2017 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" Commented Jun 19, 2017 at 20:29

2 Answers 2

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
Sign up to request clarification or add additional context in comments.

1 Comment

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
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).

1 Comment

I can run php files seperatly but not inside html file

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.