Trying to get php includes to work in an html page

by 7 replies
9
I don't want to get rid of the .html file extensions and lose the page rank. I do need to use php includes because sites just seem to keep growing. So far I've tried quite a few ways that haven't worked, and I'll list them here. Some of these were ways that worked for other people in this branch of the wafo.

These were the .htaccess statements I tired one at a time, separated by line breaks. Each blank line is a different try.

Code:
AddType application/x-httpd-php .htm .html

AddHandler application/x-httpd-php5 .html .htm

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

<FilesMatch ".(htm|html|php)$">
SetHandler application/x-httpd-php
</FilesMatch>
Each of these would not load the page, but I would get a little download type of pop up saying approximately:

The default selection is 'open with firefox.exe'

One bit of code that did work, but in the wrong way was:

Code:
RewriteEngine on
RewriteBase /
RewriteRule ^([^.]+).html$ $1.php [L]
This required changing the file extensions to .php (exactly what I don't want to do) and it left .html in the browser address bar. I also don't want to do that.

Anything else I can try?

baffled (of course that feels like normal to me now)

../lloyd
#website design #html #includes #page #php #work
  • Hello... all you should need is the following in the .htaccess (notice no periods before the page extension):
    Code:
    AddType application/x-httpd-php htm html
    • [1] reply
    • Just tried that one and it brought up the page, but the php include part was just left blank, as if it was on a html page. So basically it didn't work. (sigh)

      Nice to know about the periods though, thank you. Will definitely keep that on file, just in case.

      It might be something that would normally work, but just doesn't with my hosting.
      • [2] replies

Next Topics on Trending Feed

  • 9

    I don't want to get rid of the .html file extensions and lose the page rank. I do need to use php includes because sites just seem to keep growing. So far I've tried quite a few ways that haven't worked, and I'll list them here. Some of these were ways that worked for other people in this branch of the wafo. These were the .htaccess statements I tired one at a time, separated by line breaks. Each blank line is a different try.