Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Support

Php in iframe not working

Solved by Harald Schneider View solution

Started by Jan Hapala 4 years ago · 6 replies · 2818 views
4 years ago

I am trying to embed a simple php file in an iframe, but it is not working. A post suggests, this should be easy.

What I add into my Grav page:
<iframe id="test_iframe" title="test" src="test.php" width="600" height="600"></iframe>

However, this does not work. I get the Error 404. Interestingly, in the iframe, I can see the Grav icon and the menu of my website, something I would not expect or need inside the iframe.

When I replace the php reference with html:
<iframe id="test_iframe" title="test" src="test.html" width="600" height="600"></iframe>
the page shows up.

This is the content of test.html:

HTML
<html>
<head></head>
<body>

This is a HTML page inside IFRAME.

</body>
</html>

This is the content of test.php:

PHP
<?php

echo <<<EOL
<html>
<head></head>
<body>

This is a PHP page inside IFRAME.

</body>
</html>
EOL;

?>

Both the test.html and test.php reside in the page folder (01.home).
I am using Grav v1.7.35.

(My end goal is to reference in an iframe a locally stored map with tiles, i.e. a page referencing images from a subfolder.)

last edited 08/15/22 by Jan Hapala
4 years ago

It works with a complete URL (pointing outside the Grav folder tree).

4 years ago

Well, it does not solve my problem, though. Why can't I achieve the same having the php file within the Grav folder structure? I suppose I can, but I haven't figured out how yet. Thanks.

4 years ago

You can't because paths to PHP files inside the Grav tree are rewritten via .htaccess. So you'll have to keep it outside.

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 53 10 hours ago
Support · by Anna, 3 days ago
2 60 13 hours ago
Support · by Justin Young, 14 hours ago
1 30 14 hours ago
Support · by Duc , 1 week ago
2 65 5 days ago
Support · by Colin Hume, 1 week ago
2 56 5 days ago