开发者

dynamically create subdomain path for images

开发者 https://www.devze.com 2023-02-13 02:53 出处:网络
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. Her

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

精彩评论

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

关注公众号