Forum Moderators: coopster
<?php
include ('./footer.inc');
?>
(and then I also created a footer.inc file in the same directory)
When I added this to the html file I was working on, it didn't work! However, when I changed that same file to .php instead of .html it did work. Now I know this has to do with parsing the file....but my php books all seemed to be saying I should be able to add the above to either a html file or a php file.
Could someone please tell me if it's possible to add this to a .html file and if so, what changes would I need to make? Can you think of any advantages or disadvantages to using a php or html file? The disadvantage for me would be I would need to change the name of every file on my site and I have good search engine rank and hesitate to do that.
To make your .htm or .html pages process like they were .php, just add this line to your .htaccess file:AddType application/x-httpd-php .html .php .htm
ErrorDocument 404 [mysitedomain.com...]
AddType application/x-httpd-php .html .php .htm
and nothing else....is this correct?
Also, when I tried this using explorer it had no negative effect except it did not show the footer...however, when I tried it in Netscape and tried to pull up the pages, it instead wanted me to download them...weird :-)
Personally I just swapped over to using html extensions - simply to hide the fact I'm using php, which improves security as you're not giving away the technology behind your site, apart from that, I can't see any other reasons for it.
Personally I just swapped over to using html extensions - simply to hide the fact I'm using php
Actually, even better is to avoid using extensions at all in your URL, since this makes it easier to have permanent URLs that don't change when technology changes.
See the article on Common HTTP Implementation Problems [w3.org] by the W3C, especially guideline 3 on Using Independent URIs [w3.org].
This article is an elaboration and extension of the famous article by Tim Berners-Lee, Cool URIs Don't Change [w3.org].
Since we're on the subject, I figured I might as well post some other resources, though these are general resources on URIs that don't necessarily talk about extensions:
[www-106.ibm.com ]
[alistapart.com ]
[alistapart.com ]
[useit.com ]
Also if you add the line:
AddType application/x-httpd-php .html .php .htm
...to htaccess, but the line...
AddType application/x-httpd-php .php
...still appears there, that could be trouble. The first should replace the second.
If your put PHP code is in a .html file, what will the end user see? The footer PHP code or the footer itself?
If your server is set up to parse .html files as PHP pages (see previous posts on AddType), then it will be like any other .php page (i.e no PHP visible to user).
If it is set up to parse only .php files as PHP pages, then the user will in fact see PHP code and the HTML code you are trying to generate.
Tom
I was mistaken before because I was looking at the .htaccess file for the whole site....it WAS added to the .htaccess file for that directory.
My little php script inside the html page is calling a .inc file with has text and html in it. That way, if I want to change stuff at the bottom of the page, I only have to change one file. If you do a view source, it only shows the html after the page has been parsed by the server.