supratwinturbo Posted May 1, 2008 Share Posted May 1, 2008 Hi, I have several subdomains for my main domain. On the index.php of each sudomain, I wish to redisplay the url address but with some letters capitalized. I have the following code to get and display the url: <p> <?php $server=$_SERVER['HTTP_HOST']; echo $server; ?> </p> For example, if a user goes to http://subdomain1.domain.com, the following is displayed on the webpage: subdomain1.domain.com but I want the display to be SubDomain1.domain.com Can anyone help? Thank you, SupraTT Quote Link to comment https://forums.phpfreaks.com/topic/103682-solved-display-url-address-with-php/ Share on other sites More sharing options...
Daniel0 Posted May 1, 2008 Share Posted May 1, 2008 If they're all like subdomain<number>, then just replace the "subdomain" part. Otherwise it'd be pretty difficult to figure out programmatically when a new word starts. Quote Link to comment https://forums.phpfreaks.com/topic/103682-solved-display-url-address-with-php/#findComment-530868 Share on other sites More sharing options...
supratwinturbo Posted May 1, 2008 Author Share Posted May 1, 2008 Hi Daniel0, I understand what you mean. Let me clarify what I hope to accomplish. Basically, for each subdomain, I will have a unique index.php file. Therefore, for each subdomain, I just want to take $server and I just want to retain the main domain url (I also have several main domains, domain1.com, domain2.com, ...). So the php code I wish to accomplish will get the main domain url only (domain.com not subdomain1.domain.com). I will simply append the correct formatted subdomain string. Thank you, SupraTT Quote Link to comment https://forums.phpfreaks.com/topic/103682-solved-display-url-address-with-php/#findComment-530872 Share on other sites More sharing options...
Daniel0 Posted May 1, 2008 Share Posted May 1, 2008 Ah, then you could do <?php $domain = strstr($_SERVER['HTTP_HOST'], '.'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/103682-solved-display-url-address-with-php/#findComment-530875 Share on other sites More sharing options...
supratwinturbo Posted May 1, 2008 Author Share Posted May 1, 2008 Thanks Daniel0, works like I wanted. Quote Link to comment https://forums.phpfreaks.com/topic/103682-solved-display-url-address-with-php/#findComment-530879 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.