I put the file extension as .phtml and only in chrome it is displaying all the code. Because? [closed]

0

I put the file extension as .phtml and only in Google Chrome it is displaying the whole code of the page, but in other browsers it is interpreting normally.

The page loads into iframe . If I change the extension to .php , it works.

Can anyone tell me why this happens only in chrome?

    
asked by anonymous 04.01.2017 / 13:31

1 answer

3

I do not think it's actually working in any browser, but other browsers other than chrome should be downloading the file instead of displaying or they should be interpreting as text/html , which ignores php tags thinking they are tags html, chrome should be interpreting as plain/text .

How I responded here:

Understand that Apache , Ngnix and other equivalent servers do not use standard extensions, you actually customize it, you can even invent the extension itself if you wish , for example by editing httpd.conf in apache:

AddType application/x-httpd-php .php
AddType application/x-httpd-php .miguel

Done, it will be possible to use .miguel as an extension to run php files. You can still add index files with custom extensions for example:

<IfModule dir_module>
    DirectoryIndex index.php index.pl index.html index.htm index.miguel
</IfModule>

So that .phtml and .php are custom things anyway and if you want to add do this:

AddType application/x-httpd-php .php
AddType application/x-httpd-php .phtml

And this:

<IfModule dir_module>
    DirectoryIndex index.php index.pl index.html index.htm index.phtml
</IfModule>
  

Note: Note that not all hosting will allow you to customize your extensions, and the best thing to do is to stay in the most common way of using .php for everything, and do not use extensions

    
04.01.2017 / 14:48