Re: php scripts in html files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/20/25 10:02, François Patte wrote:
Bonjour,

I can't get working a php script in an html file: the same file:

<!DOCTYPE html>
<html lang="fr_FR">

<head>
<meta charset="utf-8" />
</head>

<body>
  <h1><?php echo 'toto' ;?></h1>

</body>

</html>

returns "toto" in toto.php and nothing in toto.html

I tried many things:

.htaccess with

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

Or modify some lines in /etc/httpd/conf.d/php.conf (FilesMatch, etc.)

Nothing had any success...

I run f40 with httpd and php from the distro.

Thanks for any help.


Follow up:

You are missing a "SetHandler" directive.

1)

The pre-existing FilesMatch line contained this:

    <FilesMatch ".+\.ph(?:ar|p|tml)$">

I changed it to this:

    <FilesMatch ".+(\.ph(?:ar|p|tml)|\.html)$">

and reloaded the web server.

I created this file in the DocRoot:

    <!doctype html>
    <html lang='en-US'>
    <?php echo 'lalala'; ?>

and saved it as "phptest.html".

My browser displayed this (view source):

    <!doctype html>
    <html lang='en-US'>
    lalala

The webserver will handle .html as php if the "FilesMatch" directive is set correctly.

2)

I don't have any "AddType" directives in the .conf or in any of the modules so I added this to the FilesMatch directive:

    AddType application/x-httpd-php .html

and reloaded the web server.

It had no effect; the header continued to display:

    content-type:  text/html; charset=UTF-8

I don't know why the web server won't honor the AddType directive.

:m


--
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux