SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
-
Apr 10, 2009, 23:45 #1
- Join Date
- Jul 2008
- Posts
- 220
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
is there a way to do this with budget shared host
i am not talking about dedicated or VPS but cheap shared hosting plan.
instead of say h t t p://w w w.EXAMPLE_DOMAIN.com?username=myname, i would like h t t p://myname.EXAMPLE_DOMAIN.com
kindda like dynamic sub domain i think.
been googled lots of sources and read through them, i still can't figure out an easy way to do this in shared host.
by the way, the host does allow editing of php.in, i mean there is a local copy of php.ini along side the server default one.
any one could help? i don't plan to move to VPS or dedicated any time soon.
or izzit possible at all creating so called dynamic sub-domain in shared host??
-
Apr 11, 2009, 15:29 #2
- Join Date
- May 2007
- Posts
- 4
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
This is possible but you'll need to be able to modify DNS A/CNAME records for the domain.
If you could add a wildcard record to the DNS zone, you could use a PHP script to 'detect' the headers from the users' browser and see what domain they typed in.
An easier way might be do to a .htaccess file and instead you could use addresses like w w w . example . c o m/username
-
Apr 11, 2009, 16:25 #3
- Join Date
- Jul 2008
- Posts
- 220
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
-
Apr 11, 2009, 18:42 #4
- Join Date
- Jul 2008
- Posts
- 220
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
finally i solved the "problem" with a 1-dollar shared host.
now i can create dynamic subdomain like h t t p://w w w.EXAMPLE_DOMAIN.com?username=myname into h t t p://myname.EXAMPLE_DOMAIN.com
whew!! it is in fact very easy to do...shame on me!!
all we need to do is to add * as subdomain in cPanel 'subdomain' menu, then set the newly created '*' subdomain point to a script file, for example 'redirect.php'
and i hv the file redirect.php like that:--
<?php
$hostname = $_SERVER['SERVER_NAME'];
$subdomain = substr($hostname, 0, strpos($hostname, '.'));
header("location: http://EXAMPLE_DOMAIN.com/index.php?username=$subdomain");
?>
very easy as long as the host has built in support for wildcard subdomain.
and i tested it on a 1-dollar cheap shared host.
-
Apr 11, 2009, 18:46 #5
- Join Date
- Jul 2008
- Posts
- 5,757
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
don't forget about subdomains like foo.bar.baz.example.com when you parse it
-
Apr 11, 2009, 18:59 #6
- Join Date
- Jul 2008
- Posts
- 220
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
well what i need is only to redirect referral link and hv a nicer URL like http://membername.E X A M P L E_DOMAIN.com ,
instead of http://E X A M P L E_DOMAIN.com/?ref=membername
parsing foo.bar.baz.example.com with regular expression is overkill.
or could you please write a function to parse every possible url string?
Bookmarks