# Running PHP code in .html files

> Make PHP code inside .html or .htm files run on Ruachost hosting, or rename the files to .php instead.

Source: https://helpcenter.ruachost.com/developers/php/running-php-in-html-files/

By default, PHP code only runs in files ending in `.php`. In a `.html` or `.htm` file, PHP code isn't run: visitors may see the code itself, or nothing at all.

## Option 1: Rename the files to .php (recommended)

Renaming `about.html` to `about.php` is the simplest and fastest option, because the server doesn't have to check every HTML page for PHP code.

To keep your old addresses working, add a redirect to the `.htaccess` file in the same folder:

```apache
RewriteEngine On
RewriteRule ^(.*)\.html$ /$1.php [R=301,L]
```

Update the links in your pages to point to the `.php` files too.

## Option 2: Tell the server to run PHP in .html files

1. In cPanel's **File Manager**, open your website's folder, for example `public_html`. Click **Settings** and tick **Show Hidden Files**.
2. Edit the `.htaccess` file (create it if it doesn't exist) and add this line at the top:

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

3. Open one of your `.html` pages in your browser to check that the PHP code runs.

This uses the PHP version you've chosen in **Select PHP Version**.

> **Caution:**
If your browser **downloads** the page instead of showing it, or you get a 500 error, remove the line you added and [open a support ticket](https://dashboard.ruachost.com/submitticket.php). We'll set it up for you.

## Related articles

- [PHP script basics](https://helpcenter.ruachost.com/developers/php/php-script-basics/)
- [Changing your PHP version and settings](https://helpcenter.ruachost.com/cpanel/software/changing-php-versions-and-settings-using-php-selector/)
