# Run PHP inside .html files
Source: https://docs.webgee.com/en/development/how-can-i-parse-html-or-htm-files-as-php



Make `.html` and `.htm` files execute PHP. Applies to shared, reseller and
Premium hosting.

This is usually needed when adding a contact form to an existing static site
whose URLs you do not want to change.

<Callout type="info">
  Consider whether you need this. Renaming the file to `.php` and adding a
  redirect from the old URL keeps the default handler and is one less thing to
  maintain. This is the right answer when the URL genuinely cannot change.
</Callout>

## The rule to use [#the-rule-to-use]

WebGee servers run LiteSpeed with CloudLinux, so this is the handler that
applies. Create or edit `.htaccess` in your document root and add:

```apache
AddHandler application/x-httpd-lsphp .html .htm
```

Save. It takes effect immediately.

## Check it worked [#check-it-worked]

Create `test.html` in your document root:

```php
<?php echo "PHP is running in .html files"; ?>
```

Visit `https://example.com/test.html`. You should see the sentence. If you see
the raw PHP code instead, the handler is not applied.

Delete `test.html` afterwards.

## If it does not work [#if-it-does-not-work]

Older documentation suggests these, which apply to Apache with different PHP
handlers and are **not** what WebGee runs:

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

Try that only if the LiteSpeed handler above does nothing. If neither works,
open a ticket rather than stacking more rules — conflicting handlers produce a
500 error that is harder to diagnose than the original problem.

You may also need file permissions of `644` on the affected files; `755` is only
required for directories.

## What this costs [#what-this-costs]

Every `.html` file on the site is now parsed by PHP, including purely static
ones. That is slower than serving them directly and prevents them being cached
as efficiently. Apply it to a specific directory rather than the whole site
where you can, by putting the `.htaccess` in that directory instead.

## Related [#related]

* [Change your PHP version and settings](/en/development/change-php-version)
* [Why PHP-FPM is not enabled on WebGee accounts](/en/development/php-handlers-why-php-fpm-is-not-enabled-on-webgee-accounts)
