php - How to refer main domain directory from sub domain wed address -
consider domain www.example.com
i if use path /images/sample.jpg in php/html file, refers www.example.com/images/sample.jpg
similarly if same www.subdomain.example.com
/images/sample.jpg --> refers www.subdomain.example.com/images/sample.jpg
but want refer image main domain without giving full web address in sub domain web page.
my main domain files ketp @ : root/www/
my subdomain files kept in : root/public_html/admin/
i may change web address later.. don't want hard code full web address in code.
if can use php or asp can use variable (or constant) placeholder host name want use. set variable in global configuration file it's accessible everywhere.
here php example using constant:
<?php define( 'host', 'www.example.com' ); ?>
then use this:
<img src="<?php echo host ;?>/images/sample.jpg">
then can change preferred host name whenever want , have update constant.
Comments
Post a Comment