homepage Welcome to WebmasterWorld Guest from 54.166.173.147
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
php inside html documents
includes function use inside html doc
OPCnewb




msg:3901546
 2:27 pm on Apr 27, 2009 (gmt 0)

I am trying to use the php includes function inside my site's .html documents, unsuccessfully I might add... Ideally, I'm wanting to have 1 file for the menu, included on my site's pages so that I only go one place to update the menu.

I've neither been able to accomplish such a feat, nor have I been able to successfully adjust the .htaccess file to successfully read php inside the html file - my end result was firefox wanting to download all .html pages I tried to visit.

Any suggestions?

 

Melter




msg:3901795
 7:36 pm on Apr 27, 2009 (gmt 0)

You need to rename all your pages that use the include as .php and not .html

Vishal




msg:3901806
 7:48 pm on Apr 27, 2009 (gmt 0)

Put this in your .htaccess file and try

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

OPCnewb




msg:3901824
 8:30 pm on Apr 27, 2009 (gmt 0)

Fixed it by adding:

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

to the .htaccess file... had to duplicate the includes folder to each subdirectory, but it did the trick...

Thank you

coopster




msg:3901979
 11:15 pm on Apr 27, 2009 (gmt 0)

Welcome to WebmasterWorld, OPCnewb.

had to duplicate the includes folder to each subdirectory

That doesn't sound right. You likely have your includes linking via relative paths. There is a message in the PHP Forum library that describes one way to control your include files [webmasterworld.com] that may be of interest to you:

g1smd




msg:3901985
 11:20 pm on Apr 27, 2009 (gmt 0)

You can set the PHP 'include' files location with one line of code in .htaccess instead.

.

*** You need to rename all your pages that use the include as .php and not .html ***

Never do this. Giving every page of your site a new URL is a very very bad idea. You lose all of your backlink credits. Every entry in any search engine SERPs returns a 404 error. Your traffic will dry up in hours, and take many months to recover. Use the AddHandler directive instead.

If you really do have to rename the files, set up a rewrite so that requests for the old .html URLs will still pull content from the new .php files, without revealing the new file names. Carry on linking to .html URLs within the site, so that people still see the same old URLs 'out on the web'.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved