apache - Redirect subdomain to PHP page and mask it -


basically has own pages setup @ domain.com/site?name=whatever

my host subdomains automatically (for example if create folder named dalton i'd automatically able visit dalton.domain.com)

anyhow want people able go whatever.domain.com , querying domain.com/site?name=whatever (i want mask still on subdomain)

any ideas? possible?

if set index.php page every subdomain points to, could

  • retrieve "subdomain" part of url
  • create iframe contains actual page want show

this typically how lot of domain-hosting companies "masking".


index.php (abridged):

<?php     //get subdomain     $subdomain = array_shift((explode(".",$_server['http_host'])));      //rewrite url     $url = "http://www.domain.com/site?name=" . $subdomain;      //create page     echo "<!doctype html><html><head><title>page title</title></head><body style='margin:0;padding:0;'>";      //create full-screen iframe page url     echo '<iframe src="'.$url.'" style="border: 0; width: 100%; height: 100%"></iframe>';      //close page     echo "</body></html>"; 

alternatively, can handle entirely .htacccess:

.htaccess (abridged):

#use rewrite engine rewriteengine on  #doesn't start "www." rewritecond %{http_host} !^www\.  #check url "something.domain.com" rewritecond %{http_host} ^(.*)\.domain\.com  #capture subdomain , rewrite rewriterule ^(.*)$ http://domain.com/site?name=/%1/$1 [l,nc,qsa] 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -