Answer the question
In order to leave comments, you need to log in
How to display image via php script without changing url?
Interested in the question, is it possible with the help of a web server, php and tricks to display an image in a "wrapper".
Given: there is an image on the server (nginx), it is available at the URL //server.domain/image.png and is displayed correctly.
I want to: when accessing the URL of an image, display not only the image itself, but also a menu bar at the top of the screen. Ideally, a stylized page, but without a redirect to page.php. That is, when accessing //server.domain/image.png, it is not the image itself that opens, but the page containing this same /image.png, but the URL remains //server.domain/image.png
Answer the question
In order to leave comments, you need to log in
location /img/pilipchuk {
rewrite ^/img/pilipchuk/(.*)$ /obertka/index.php?url=$1 last;
try_files $uri @fallback;
}
location /img/getPilipchuk {
rewrite ^/img/getPilipchuk/(.*)$ /obertka/load.php?url=$1 last;
try_files $uri @fallback;
}
/public_html$ ls obertka/
index.php load.php
folder with images
public_html$ ls img/pilipchuk/
logo.png
index.php files
<?php
print_r($_GET);
echo "<div style='width:100%;'>Hello VOVAN</div><br>";
echo "<div><img src='/img/getPilipchuk/{$_GET['url']}'></div>";
?>
<?php
echo file_get_contents("./../img/".$_GET['url']);
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question