Forum Moderators: coopster & phranque

Message Too Old, No Replies

Perl and PHP in .html

Plz I need to make this work

         

stroggoff

4:17 pm on Mar 16, 2003 (gmt 0)

10+ Year Member



Here 's my latest trouble:

In my httpd.conf there is a line that says :
AddType application/x-httpd php .php .php4 .html

and so I can put php code in .html files
However recently I found out that when an .html file contains perl code the server prompts me for download.
This is not good since I have a whole site ready , based on mod_perl and written in .html files ,and I have to make it work simultaneously with the php .html files ...

if this makes any sense to you, plz help me ..

gsx

5:43 pm on Mar 16, 2003 (gmt 0)

10+ Year Member



I don't think you can use php and perl together that way. If the server sees a html file it has to be one thing, it can't be php or perl, it must be php (thus all files ending html are php) or perl (all files ending html are perl).

What about:
AddType application/x-httpd php .php .php4 .html
AddType application/x-httpd cgi .cgi .htm

Or something like that. Then the server knows html are php files and htm are perl files.

nosanity

9:07 am on Mar 17, 2003 (gmt 0)

10+ Year Member



I would actually try using AddHandler instead of AddType

AddType application/x-httpd-php .php .php3 .phtml
AddType application/x-httpd-php-source .phps
AddHandler application/x-httpd-php .html

AddType cgi-script .cgi
AddType perl-script .pl
AddHandler perl-script .htm

.php, .php3, .phtml, and .html will all be handled by PHP.
.cgi will be handled like any normal CGI script.
.pl, and .htm will both be handled by mod-perl.

Might mean you will need to change a few links on your existing work, but will ensure it all works in the end.

noSanity

PS: You can swap .htm and .html so you won't have to change so many links......

Allen

10:32 am on Mar 17, 2003 (gmt 0)

10+ Year Member



Could you not use .htaccess files to do this on a per site basis?

Allen

stroggoff

10:36 am on Mar 17, 2003 (gmt 0)

10+ Year Member



Thanx to all of you for your replies.
Actually today I found a compromising solution. I removed those AddType lines from httpd.conf
and created new .htaccess files with these lines only, in the root directories of my php sites.
Since I have php-only sites and perl-only sites but not
php_AND_perl sites this solution to work so far ,plus I didn't have to go through all links to change them from html to htm ...

Anyway thanx again

andreasfriedrich

11:15 am on Mar 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Using the <Directory> [httpd.apache.org] or <Location> [httpd.apache.org] directives will be more efficient than .htaccess files.

Andreas