SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Jul 2008
    Posts
    220
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Question 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??


  2. #2
    SitePoint Member
    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

  3. #3
    SitePoint Addict
    Join Date
    Jul 2008
    Posts
    220
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Makdaddi View Post
    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
    i had done that. it is like MOD Rewrite, right? very common with URL shortener script.

  4. #4
    SitePoint Addict
    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.

  5. #5
    SitePoint Wizard bronze trophy
    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

  6. #6
    SitePoint Addict
    Join Date
    Jul 2008
    Posts
    220
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by crmalibu View Post
    don't forget about subdomains like foo.bar.baz.example.com when you parse it
    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?


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •