Forum Moderators: mack

Message Too Old, No Replies

html, htaccess, php, and iframe

adding htaccess file to put php into html pages ruins iframe

         

GeorgeStJohn

5:29 am on Aug 19, 2007 (gmt 0)

10+ Year Member



I have a website with a few hundred HTML pages. I also have a WordPress blog on the same website. For the past year I have used an RSS feed to put recent posts from the blog onto the homepage. To do so, I had to change the homepage from a .htm to a .php page. But this was no problem because all the links to the homepage specify the root folder and not the index.___ file itself.

Now I would like to add some blog content on other pages throughout the website. However, I don't want to change all of the .htm extensions to .php extensions. There are too many of them and too many interpage links.

I discovered some code to put into a .htaccess file which is supposed to cause HTML pages to be parsed as if there are PHP pages whether or not they have any PHP content. This seemed ideal. I created a .htaccess file (there wasn't already one) and put this into it.

--------------
addtype application/x-httpd.php .php
addtype application/x-httpd.php .html
addtype application/x-httpd.php .htm
--------------

I know nothing about .htaccess, but I saw many sites that recommended this (or similar htaccess code) as a solution to my problem. So far, so good.

However, as soon as I placed the .htaccess file in the root of my website server (same folder where the homepage is), I immediately had a problem with content in an iframe. Instead of displaying the content in the iframe properly, as it always had done, FoxPro put up a dialogue box asking if I wanted to ignore the file (the HTML file to be loaded into the iframe) or if I wanted to download it. If I selected download, then the file was displayed in a separate tab of the FireFox browser.

Obviously, this is no good. Is there a way to show content in iframes and at the same time include PHP content on HTML pages (pages with .htm extensions) using .htaccess to the server to parse the HTML files as if they are PHP files?

Many thanks,

GSJ

Receptional Andy

2:41 pm on Aug 20, 2007 (gmt 0)



This might be just a server config thing, but on the servers I checked it is application/x-httpd-php as opposed to application/x-httpd.php so you may want to try switching those.

Alternatively, you may want to try addhandler instead of addtype:


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

GeorgeStJohn

3:58 am on Aug 21, 2007 (gmt 0)

10+ Year Member




Thanks, but I am still having problems here.

Using "application/x-httpd-php" caused the problem with the iframes.

But using "AddHandler application/x-httpd-php .php .htm .html" doesn't parse the PHP content in the HTML pages.

I am at a loss here. Any additional help would be much appreciated.

Receptional Andy

12:45 pm on Aug 21, 2007 (gmt 0)



Using "application/x-httpd-php" caused the problem with the iframes

Just to clarify, I mentioned this because in the example you posted first there's a dot in 'x-httpd.php' whereas on the servers I use all three words are separated by hyphens.

GeorgeStJohn

1:49 am on Aug 24, 2007 (gmt 0)

10+ Year Member




Using "application/x-httpd-php" caused the problem with the iframes

Thanks. I understand that there should be a dash, not a dot.

I am still having the same problem I described in the first post. I am continuing to try different forms of the htaccess code.

GeorgeStJohn

3:40 am on Aug 24, 2007 (gmt 0)

10+ Year Member



The latest one I've tried:

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

Still the same problem.

Regardless of whether it causes HTML files to be parsed as PHP (and it does not seem to), it causes problems with the iframe.