dynamically create subdomain path for images
I'm looking for a PHP script that will rewrite my image paths to a subdomain. I curre开发者_Go百科ntly have a script that performs this action, but it's difficult to use on my local development. Here is my current script:
<?php
$IMG_BASE_URL1="http://img.mysite.com/";
?>
...and then for the image...
<img src="<?php echo $IMG_BASE_URL1; ?>images/ui/logo.png">
This works great but it doesn't allow me to see the images locally while I'm developing the page. Is there a way to globally load the images from my subdomain without including <?php echo $IMG_BASE_URL1; ?>
in the src path?
If you're on Apache (?) you could setup a virtual host to simulate your subdomain.
Here's a nice article on it, I've done it a few days ago: http://apptools.com/phptools/virtualhost.php
精彩评论