# .htaccess does not seem to be working

**URL:** <https://forum.infinityfree.com/t/htaccess-does-not-seem-to-be-working/55958>\
**Category:** Hosting Support\
**Created:** [December 20, 2021, 11:38am UTC](https://forum.infinityfree.com/t/htaccess-does-not-seem-to-be-working/55958 "2021-12-20T11:38:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon42989280](https://forum.infinityfree.com/letter_avatar/anon42989280/32/6_449c533f586939b6e5f246632a46421f.png) [@anon42989280](https://forum.infinityfree.com/u/anon42989280)\
**Post date:** [December 20, 2021, 11:38am UTC](https://forum.infinityfree.com/t/htaccess-does-not-seem-to-be-working/55958/1 "2021-12-20T11:38:58Z")

</div>

### Username

epiz\_30561595

There is no error message from what I have seen, but nothing seems to be working…

I’m trying to get php code into .html files. It does not work by default, and that’s fine. I create a .htaccess file in the htdocs file in my directory, at put in the following code:

AddType application/x-httpd-php .htm .html

I save the file and try to make php code in an html file, but it’s not doing anything. I think it’s that the .htaccess isn’t working.  
I have not found any error messages. (In the file or the website page)

---

<div class="post-metadata">

**Author:** ![wackyblackie](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/wackyblackie/32/43350_2.png) [@wackyblackie](https://forum.infinityfree.com/u/wackyblackie)\
**Post date:** [December 20, 2021, 11:54am UTC](https://forum.infinityfree.com/t/htaccess-does-not-seem-to-be-working/55958/2 "2021-12-20T11:54:12Z")

</div>

Put this in your .htaccess (at the very top) to see if there are really any errors with itself/your php:

```auto
php_value display_errors On

```

And if that doesn’t work, maybe change the file extension to `.php`. Then you can use a .htaccess RewriteRule to change the visible extension in the browser url:

> [@Custom File Extensions (.htaccess)](https://forum.infinityfree.com/t/custom-file-extensions-htaccess/42159):
>
> Introduction Hello, I am @anon68194040 and i will be doing a tutorial on how to make your own custom file extension and use it on your website. If you wanna run that .php file as an .awesomescript file then thisis the right tutorial for you. .htaccess htaccess if a file that lets you rewrite paths and also disable indexes but did you also know you can rewrite file extensions? It’'s true. The code of the .htaccess file should be: RewriteEngine on RewriteRule ^(.\*)\.phpx$ $1.php Now what w…

---

<div class="post-metadata">

**Author:** ![jaikrishna.t](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/jaikrishna.t/32/57109_2.png) [@jaikrishna.t](https://forum.infinityfree.com/u/jaikrishna.t)\
**Post date:** [December 20, 2021, 12:22pm UTC](https://forum.infinityfree.com/t/htaccess-does-not-seem-to-be-working/55958/3 "2021-12-20T12:22:15Z")

</div>

You cannot use PHP in a `.html` file, your extension needs to be `.php`. Correct me if I misunderstood.

---

<div class="post-metadata">

**Author:** ![Admin](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/admin/32/36437_2.png) [@Admin](https://forum.infinityfree.com/u/Admin)\
**Post date:** [December 20, 2021, 12:23pm UTC](https://forum.infinityfree.com/t/htaccess-does-not-seem-to-be-working/55958/4 "2021-12-20T12:23:28Z")

</div>

By far the easiest way to make sure your PHP code gets executed is to put the code in a file with the `.php` extension. That’s guaranteed to work on every server that supports PHP.

If you want `.html` in your URLs, you can also just setup your code with the `.php` file extension and then use .htaccess RewriteRules to dynamically rewrite all `.html` URLs to `.php`. This example does that: [.htaccess - redirect all .html extensions to .php - Stack Overflow](https://stackoverflow.com/a/5990276)

For going to route you took, I’m not sure if that works here. It might be that the line is wrong, I see examples with `AddHandler` instead of `AddType` and different content types too. And it might be that these .htaccess directives are not allowed on our hosting.

---

<div class="post-metadata">

**Author:** ![anon92572883](https://forum.infinityfree.com/letter_avatar/anon92572883/32/6_449c533f586939b6e5f246632a46421f.png) [@anon92572883](https://forum.infinityfree.com/u/anon92572883)\
**Post date:** [December 22, 2021, 10:49am UTC](https://forum.infinityfree.com/t/htaccess-does-not-seem-to-be-working/55958/5 "2021-12-22T10:49:08Z")

</div>

I thought that was the rule as well.

---

<div class="post-metadata">

**Author:** ![wackyblackie](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/wackyblackie/32/43350_2.png) [@wackyblackie](https://forum.infinityfree.com/u/wackyblackie)\
**Post date:** [December 22, 2021, 12:50pm UTC](https://forum.infinityfree.com/t/htaccess-does-not-seem-to-be-working/55958/6 "2021-12-22T12:50:42Z")

</div>

This is generally the case if you do not set up any server-side processing rules. But, as we solved in this topic, you can if you write some server-side rules (.htaccess rules) to do so.

---

<div class="post-metadata">

**Author:** ![system](https://infinityfree-forum-uploads.s3.dualstack.eu-central-1.amazonaws.com/original/3X/b/0/b024fd3fa88bae093c9576e55c2c94e33f890206.svg) [@system](https://forum.infinityfree.com/u/system)\
**Post date:** [December 29, 2021, 12:51pm UTC](https://forum.infinityfree.com/t/htaccess-does-not-seem-to-be-working/55958/7 "2021-12-29T12:51:19Z")

</div>

Closed on December 29, 2021, 12:51pm UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
