开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜