COMPUTICA
09-12-2002, 09:56 PM
Is there something I can edit in the httpd.conf so that any pages with a .php extension will also be parsed for SSI code?
I appreciate any help.
I appreciate any help.
![]() | View Full Version : Can I Edit httpd.conf so that .php will be parsed by SSI? COMPUTICA 09-12-2002, 09:56 PM Is there something I can edit in the httpd.conf so that any pages with a .php extension will also be parsed for SSI code? I appreciate any help. COMPUTICA 09-12-2002, 10:00 PM Sorry....forgot to mention..... ...that I have a RaQ4r that I am trying to do this on...... blazeman 09-13-2002, 12:37 AM are you wating PHP and SSI to both be parsed or just one or the other? If you want both... I don't think that is possible... if you just want SSI with the page extesntion to be PHP... yeah... you can do that i am a 09-13-2002, 01:17 AM well you could, but why would you want to? parsing a .php file for both php and SSI will add well, will add overhead... :) and there isn't much you can do in SSI that you coudln't accomplish in php i'd imagine.. anyhow, if you're really really wanting to do so, either in a .htaccess file or httpd.conf add: AddHandler server-parsed .shtml .php AddType application/x-httpd-php .php you probably already have most of that in there anyhow.. the first allows .shtml and .php to be parsed by SSI, the second allows php to parse .php COMPUTICA 09-13-2002, 11:24 AM Here is an explanation of why we are looking at doing this, maybe some of you have some better ideas... Now, we build 90% of the web sites we develop for clients using SSI. The main page is .SHTML and we have includes for things like the header, the nav, footer, content, etc.... Obviously so that updates are easy since we only have to update the single file. Now we are getting into providing some higher end applications (no more business card web sites) that need some PHP to be run within them. If we build a SSI page that calls in a PHP page, that PHP page is not getting parsed for PHP code. So, we thought it would be easiest if we could get a PHP page to be parsed for SSI. Then, we should be able to include .PHP pages and have them properly parsed for PHP.... Correct? Wrong? Any better way to do this, yet still accomplish the same results? allera 09-13-2002, 11:34 AM How about just using PHP instead of PHP+SSI? SSI Code: <!--#include file="/web/includes/main_header.htm" --> PHP Code: <?include("/web/includes/main_header.htm");?> That way you get rid of SSI w/o losing the functionality. What can SSI do that PHP can't? COMPUTICA 09-13-2002, 11:41 AM Okay, in my mindset (developing web pages for 10 years) of using only SSI, I admit I never even thought of that! LOL!!! BUT.... I just tried that, and now when I try to go to PAGENAME.PHP that has the include code within it, it won't bring up the page.....just trys getting me to download it to my computer (pop's up the save as box).... Any ideas? allera 09-13-2002, 11:44 AM Did you mess with Apache when trying to do the PHP+SSI dance? Make sure you set things back to normal (backup?): AddHandler server-parsed .shtml AddType application/x-httpd-php .php That should work. COMPUTICA 09-13-2002, 11:50 AM Yes, I had added the .PHP extension to the httpd.conf where the domain name was listed, but I restored the backup I made before I made any changes (yes, I remembered to back it up :D ) and restarted apache. Still didn't effect anything........ Here is an excerpt of the code for the domain within httpd.conf: <VirtualHost 123.123.12.12> ServerName www.domainname.com ServerAdmin admin DocumentRoot /home/sites/site57/web ServerAlias domainname.com www.domainname.com RewriteEngine on RewriteCond %{HTTP_HOST} !^123.123.12.12(:80)?$ RewriteCond %{HTTP_HOST} !^www.domainname.com(:80)?$ RewriteRule ^/(.*) http://www.domainname.com/$1 [L,R] RewriteOptions inherit AliasMatch ^/~([^/]+)(/(.*))? /home/sites/site57/users/$1/web/$3 AddHandler cgi-wrapper .cgi AddHandler cgi-wrapper .pl AddHandler server-parsed .shtml AddType text/html .shtml AddType application/x-httpd-php .php4 AddType application/x-httpd-php .php # AddHandler chiliasp .asp # AddHandler chiliasp .asa </VirtualHost> Website Rob 09-13-2002, 03:14 PM OK, I'm no PHP guru -- it was an interesting challenge though -- and this is what I was able to come with running PHP in safe-mode: php_includetest.html -------------------------------------------------- <div align="center"> <br /> <br /> include_file.php - local file - shown below: <br /> <br /> <!--#include virtual="include_file.php" --> </div> include_file.php -------------------------------------------------- <p><strong><?php echo('Hello World'); ?></strong></p> <?php $ip = $HTTP_SERVER_VARS["REMOTE_ADDR"]; echo ('My IP Address is: '); echo $ip; ?> Seems to work for me? One difference I did not notice is that: AddHandler server-parsed html is not used. Throw that in your httpd.conf or .htaccess file so you don't have to use "*.shtml" format. I have noticed I run into problems with that format and certain Apache calls. COMPUTICA 09-13-2002, 04:02 PM Still didn't work for me..........here is a copy of the code I am attempting to call, the file name is: index.php ------------- Start <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>web site title</title> <body bgcolor="#000000" text="#000000" link="#AE4245" alink="#AE4245" vlink="#AE4245"> <center> <table cellpadding="0" cellspacing="0" border="0" width="600" valign="top"> <tr> <td width="600" colspan="2" valign="top" bgcolor="#000000"><?include("header.html");?></td> </tr> <tr> <td width="130" valign="top" bgcolor="#000000" background="images/left_bar.jpg"><?include("left.html");?></td> <td width="470" valign="top" bgcolor="#FFFFFF"><?include("welcome.html");?></td> </tr> <tr> <td width="600" height="1" colspan="2" valign="top" bgcolor="#AE4346" background="images/footer.jpg"><img src="images/footer.jpg" height="1" width="600" border="0" hspace="0" vspace="0" alt=""></td> </tr> <tr> <td width="600" colspan="2" valign="top" bgcolor="#000000"><?include("footer.html");?></td> </tr> </table> </center> </body> </html> ------------- End I am not a PHP guru either, so maybe my problem lies within this code.... :confused: Website Rob 09-13-2002, 04:48 PM A) <?include("header.html");?> is incorrect, should be <?php include("header.html"); ?> B) why use PHP when you can use SSI? I had thought you were trying to pull a PHP file into an HTML file. Your example doesn't show that. I would just use straight SSI if that's what you want to do. Remember to add the: AddHandler server-parsed html If not, you'll have to use "*.shtml" instead. COMPUTICA 09-13-2002, 05:03 PM I really don't want to have regular .HTML files parsed by the server......that would increase the work the server has to do 10 fold at least........parsing every .SHTML file, and then every .HTML file as well....... Originally, I was looking at including a PHP file into an SHTML page....then, when it was mentioned that I could just use the PHP include command to bring in other files, that is where I moved on to.... Now, I am trying to successfully get a PHP page to display, including the files it is supposed to include. Right now, even with your corrected code placed within my HTML code, I still get the immediate pop-up box asking me to save the file on my hard drive..... :confused: Website Rob 09-13-2002, 05:56 PM I really don't want to have regular .HTML files parsed by the server......that would increase the work the server has to do 10 fold at least........parsing every .SHTML file, and then every .HTML file as well....... That may have been true at one time, but is now a fallacy. Any decent Server can handle the load with no problem. Since you've already got a combination of both though, should probably keep things the way they are. Originally, I was looking at including a PHP file into an SHTML page....then, when it was mentioned that I could just use the PHP include command to bring in other files, that is where I moved on to.... If you were to practice a bit with the code of the two files I mentioned above, you should be able to do that. Change the format from "*.php" to "*.shtml" and see what happens. Since you are using "*.shtml" files anyway. The example worked fine for me, but as I said, I've sometimes run into problems using the "*.shtml" format which is why I don't use it. Now, I am trying to successfully get a PHP page to display, including the files it is supposed to include. Looks like I need more practice with PHP. Appears this is the coding for an include: <?php include 'file.php'; ?> but I don't know how well it works with HTML files -- it should with no problem. Make sure though, the path to the "include" file is correct. Right now, even with your corrected code placed within my HTML code, I still get the immediate pop-up box asking me to save the file on my hard drive.....If you still have problems (still getting the download window -- indication of incorrect MIME type) then merge your two lines into one: AddType application/x-httpd-php .php4 .php CmptrWz 09-13-2002, 06:23 PM While we are at it: <?php include("file"); ?> Is the best format. Start with <?php then put a space, then the include("file"); command, don't forget the semicolon, then another space, then the ?> Doing this makes it so that the server knows it is PHP(other languages use <? ?> as well), and that it doesn't get the start/end tags confused with the PHP script. i am a 09-13-2002, 09:34 PM i'd suggest taking a moment (if you have the time) to learn php as it'll provide a lot more functionality that SSI can and be faster anyhow.. you can basically do anything in SSI in php and faster and more efficient code wise, it may be a bit confusing from the get go but you'll definitely stick with just PHP vs SSI in the future i would think... the docs are excelelnt, just use the syntax php.net/FUNCTION is you want help on somethnig (ie. php.net/include or php.net/print or php.net/mysql_connect) |