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.
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.
Bonjour François,
I've never seen or used php where .html is assigned to the php handler. Is there any particular reason you want/need to use the .html extension on php?
If you use .php as the file extension does it render as you expect?
Mike Wright
Le 2025-03-20 21:24, Mike Wright a écrit :
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.
Bonjour François,
I've never seen or used php where .html is assigned to the php handler. Is there any particular reason you want/need to use the .html extension on php?
If you use .php as the file extension does it render as you expect?
Merci.
It is just lazyness... I want to add php includes (like menu...) into html files and I don't want to have to rename all files for this purpose...
I can see on the web people able to have this feature working, but, as far as I can see, they all use other distro, so I am wondering if there is some hiden config in fedora...
Regards.
the same process should work under fc. find a site that has what you want to test. make sue it sets up ur server with the appropriate settings modules etc. and test it. it should work.
On Thu, Mar 20, 2025, 5:39 PM François Patte < francois.patte@mi.parisdescartes.fr> wrote:
Le 2025-03-20 21:24, Mike Wright a écrit :
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.
Bonjour François,
I've never seen or used php where .html is assigned to the php handler. Is there any particular reason you want/need to use the .html extension on php?
If you use .php as the file extension does it render as you expect?
Merci.
It is just lazyness... I want to add php includes (like menu...) into html files and I don't want to have to rename all files for this purpose...
I can see on the web people able to have this feature working, but, as far as I can see, they all use other distro, so I am wondering if there is some hiden config in fedora...
Regards.
-- François Patte UFR de mathématiques et informatique Laboratoire CNRS MAP5, UMR 8145 Université Paris Descartes 45, rue des Saints Pères F-75270 Paris Cedex 06 Tél. +33 (0)6 7892 5822 http://www.math-info.univ-paris5.fr/~patte -- _______________________________________________ users mailing list -- users@lists.fedoraproject.org To unsubscribe send an email to users-leave@lists.fedoraproject.org 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@lists.fedoraproject.org Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue
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
On 3/20/25 14:39, François Patte wrote:
Le 2025-03-20 21:24, Mike Wright a écrit :
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.
Bonjour François,
I've never seen or used php where .html is assigned to the php handler. Is there any particular reason you want/need to use the .html extension on php?
If you use .php as the file extension does it render as you expect?
Merci.
It is just lazyness... I want to add php includes (like menu...) into html files and I don't want to have to rename all files for this purpose...
This will do what you want:
In each directory with .html files:
for f in `ls *html`; do mv "$f" "${f%.html}.php"; done
:m
I can see on the web people able to have this feature working, but, as far as I can see, they all use other distro, so I am wondering if there is some hiden config in fedora...
Regards.
On Thu, 2025-03-20 at 18:02 +0100, François Patte wrote:
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'm not sure that's a wise idea. Now the server would have to parse every .html file looking for PHP, rather than just the .php files.
Though I do something similar for server side includes, any page with a .shtml suffix, or any .html page with the X bit set is parsed. But not every .html file is parsed, because it doesn't need it.
On 3/20/25 23:36, Tim via users wrote:
On Thu, 2025-03-20 at 18:02 +0100, François Patte wrote:
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'm not sure that's a wise idea. Now the server would have to parse every .html file looking for PHP, rather than just the .php files.
+1 Very good point!
Though I do something similar for server side includes, any page with a .shtml suffix, or any .html page with the X bit set is parsed. But not every .html file is parsed, because it doesn't need it.
Hi.
Server Side Scripting.. on my todo to research further.. I seem to recall the basic tech was to have "stuff" inserted in the html for execution on/by the server process.. Am I off base in recalling.
At the same time, what does the implementation of SSI/HTML do that can't be easily handled by a php/html combination.
I've got a feeling others have a curiosity as well.
thanks
On Fri, Mar 21, 2025 at 9:51 AM Mike Wright nobody@nospam.hostisimo.com wrote:
On 3/20/25 23:36, Tim via users wrote:
On Thu, 2025-03-20 at 18:02 +0100, François Patte wrote:
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'm not sure that's a wise idea. Now the server would have to parse every .html file looking for PHP, rather than just the .php files.
+1 Very good point!
Though I do something similar for server side includes, any page with a .shtml suffix, or any .html page with the X bit set is parsed. But not every .html file is parsed, because it doesn't need it.
-- _______________________________________________ users mailing list -- users@lists.fedoraproject.org To unsubscribe send an email to users-leave@lists.fedoraproject.org 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@lists.fedoraproject.org Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue
On Fri, 2025-03-21 at 17:06 +1030, Tim via users wrote:
I'm not sure that's a wise idea. Now the server would have to parse every .html file looking for PHP, rather than just the .php files.
Supplemental info that may be related to why the original poster is thinking of doing this...
Many years I turned on content-negotiation on my server. And instead of my links being explicit href="contact-details.html" they are simply href="contact-details" and the actual page could be a .html file today, and .asp file tomorrow, or rewritten as a .php file the next week.
I don't have to change any of the links on any pages, they work for whatever contact-details.something file that I store on the server, the server automatically picks it out. As my needs for that page change, I can simply swap it out for a different kind of file.
Also, it handled things like href="printer-maintenance" being a link to one page this week, but next week it's a link to a folder, with a page in that folder linking to many other adjacent pages that expand on topics. A whole page to opening the printer to remove paper jams, a whole page just for how to refill the toner, etc.
It works brilliantly on Apache. It's a shame that my current hosting provider decided to ditch Apache (free software) for LightSpeed (commerical software), and it's not the drop-in replacement for Apache that LightSpeed claims it is. And my hosting provider buggers up the configuration in various ways, too.
Content negotion is not just for links written in the pages, but anything someone wants to access.
e.g. http://example.com/explanation is a nice neat link written in the modern style that will load the page that otherwise you would have accessed by http://example.com/explanation.shtml
On Fri, 2025-03-21 at 10:05 -0400, bruce wrote:
Server Side Scripting.. on my todo to research further.. I seem to recall the basic tech was to have "stuff" inserted in the html for execution on/by the server process.. Am I off base in recalling.
At the same time, what does the implementation of SSI/HTML do that can't be easily handled by a php/html combination.
SSI allows something to be generated externally (by the server, rather than in your browser) and the results inserted into the page.
Apache has a number of built-in features, such as letting you insert a filedate (e.g. this page was last updated on...), and it can insert the results from external code (and as far as I'm aware, it's whatever languages you can run on the computer).
PHP is similar in concept, perhaps with an advantage that what you learn to code in PHP on one computer system should be directly workable on another computer system (with a compatible version of PHP).
I could code a BASH script on Linux to do a function, or compile a Linux executable, etc. But if I then had to move onto a Windows host, I'd probably have to write new code.
The disadvantages of various languages for web pages is that people often don't write their own code, but grab things other people wrote, and often don't vet their suitability or security. That applies whether its PHP, Perl, JavaScript, or anything else.