Can some one help me out in this? I want to know the codes for a Php if, else condition tags based on URL. I want it like, if url=domain.com echo <div> dont show domain button<div> else echo <div> dont do nothing </div> and if url=something.domain.com echo <div> dont show something button <div> else echo <div> do nothing </div> I hope you got the thing from the Framework i.e When running on the domain url, i dont want to see domain link on the page in the nav bar i make. and when am in the subdomain, i dont want to see that subdomian link in nav bar. I can arrange the things for navbar. but not so sure about the PHP code. Can some one help me out and clear this giving me the code? also i would like a wildcard it the cases like if it is domain.com/* so it remain correct for all the pages in the blog
<?php $url = str_replace("www.", "", $_SERVER['HTTP_HOST']); if ($url == "domain.com") { echo "<div>dont show domain button</div>"; } else { echo "<div>dont do nothing</div>"; } if ($url == "something.domain.com") { echo "<div>dont show something button</div>"; } else { echo "<div>do nothing</div>"; } ?> PHP:
Thanks For the Time spent for framing the code. Actually i tried using it, But Only the First If and Else Gets Exceuted and result shows. I.e Subdomain has no changes visible Why is that?
Try this <?php $url = str_replace("www.", "", $_SERVER['HTTP_HOST']); switch ($url) case 'domain.com': { echo "<div>dont show domain button</div>"; break; case 'something.domain.com': echo "<div>dont show domain button</div>"; break; default: echo "<div>dont do nothing</div>"; break; } PHP: And say the Results