Welcome to WebmasterWorld Guest from 54.226.246.160

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

php inside html documents

includes function use inside html doc

     

OPCnewb

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

5+ Year Member



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

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

10+ Year Member



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

Vishal

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

10+ Year Member



Put this in your .htaccess file and try

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

OPCnewb

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

5+ Year Member



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

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

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

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

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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'.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month