title: Detect URL that app is being accessed from
body: <p>I am currently developing a PHP application that is (hopefully) going into production use soon.</p>
  
  <p>What I'm needing help with is detecting what URL the app is being accessed on ie dev.local, testing.domain.com or app.domain.com and then using the correct MySQL DB, ie app_test for dev and testing and app_prod for the production server.</p>
  
  <p>Along with that, I also want to be able to modify the internal URLs to match (several emails are sent that also need to be tested with the correct URL).</p>
  
  <p>I remember seeing some stuff about it before but am not able to find it any more.</p>