Ok - Im looking for something a bit off kilter here. I have a site right now that mimics tinyurl. basically you put in a long URL and and it returns you a small URL. right now the format is mydomain.com/smallurl I want to add functionality so I could this : smallurl.mydomain.com What I think I have to do is mod my https.conf file to allow *. subdomains. then add a mod rewrite rule to hit my php code to lookup the "smallurl" Does that sound right? Any other ideas?
Yes. That's is basically. You first need wildcards subdomains, that *.yourdomain.com points to some PHP file (or maybe just the index of your site), and then trough htaccess redirect to the proper directory,website or whatever. Also, you could just use PHP to analyze the requested URL (subdomain) and redirect the user to the site, if that's located in the database. As for example: <?PHP $data=explode(".mydomain.com",strtolower($_SERVER['SERVER_NAME'])); $data=$data[0]; $data=str_replace("www.","",$data); if($data){ include("../connect.php"); $result=mysql_query("SELECT * FROM links WHERE id LIKE '%$data%'",$conn); while($link = mysql_fetch_array($result)){ if(strtolower($link[id])==$data){ header("location: $link[website]"); break; exit; } } } echo"<meta http-equiv=\"refresh\" content=\"2;URL=http://www.mydomain.com/\">The code <b>$data</b> doesnt represent a valid tiny url.<br><br>Please wait while you are being redirected to the main site."; ?> PHP:
yeah six.sigma is on the right way. but it goes tighter. setup wildcard "*" subdomains to point at your tinyurl-service, so it is reachable from all subdomains and then add the following code on top of your index.php file, right after the <? $id=eregi_replace("YOURDOMAIN\.COM","",$_SERVER[HTTP_HOST]);if(!$id=="") {$id=eregi_replace("\.$","",$id);header("Location: http://YOURDOMAIN.COM/$id");die;} Code (markup): then add the code in the tinyurl-script that the url that´s given to the user also lists offers the subdomain variant. but be aware, that the subdomain-solution is slightly slower, since each new-called subdomain creates also another DNS-request at the users end.