This is not possible with relative paths, because the subdomain is actually a completely different area.
If you really cannot use the absolute URL, but can use PHP, you can try this proxy script:
<?php if(!isset($_GET['url'])) { die('Missing URL!'); } $subdomain_url = 'http://subdomain.example.com/'; $file_path = $_GET['url']; $file_url = $subdomain_url . $file_path; $mime = finfo_open(FILEINFO_MIME, $file_url); header('Content-Type: ' . $mime); header('Content-Transfer-Encoding: Binary'); header('Content-disposition: inline; filename="' . basename($file_path) . '"'); readfile($file_url);
Save it to a file, for example. imgproxy.php, and then you can link the images to another subdomain as follows:
<img src="imgproxy.php?url=images/logo.png">
Mightypork
source share