CodeIgniter Forums
Basecamp like Urls *Permalinks*? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Basecamp like Urls *Permalinks*? (/showthread.php?tid=3340)



Basecamp like Urls *Permalinks*? - El Forum - 09-25-2007

[eluser]Jamongkad[/eluser]
Hi guys I would like to get the collective wisdom of peeps in regards to this problem of mine. I would like to know how web apps like Basecamp create dynamic permalink urls. To those who haven't used Basecamp yet, a short explanation...

Firstly you register with 37Signals and you are presented with a reg form. There you plug in the details of your company etc etc. By that time you will be presented with a drop down box that asks for your company name and attaches some kind of url to it. e.g Companyname.grouphub.com something to that effect.

My question is how does Basecamp do this? the ability to create dynamic permalinks that bring you to your Basecamp account. My second question is how can CI do this as well?

Thanks!


Basecamp like Urls *Permalinks*? - El Forum - 09-25-2007

[eluser]Kemik[/eluser]
They use ruby on rails I believe. However, I suppose you might be able to use routing or something like that? Not 100% sure.


Basecamp like Urls *Permalinks*? - El Forum - 09-25-2007

[eluser]champs[/eluser]
Nothing magical or Rails-specific about it.

First, you need wildcard DNS set up, a web server willing to accept all the hostnames, and just a couple lines of PHP in your controller:

Code:
<?php
// like, such as, 'maps.example.com'
$host = strtolower($this->input->server('HTTP_HOST'));

// and now we'll get: array('maps', 'example', 'com');
$account = explode('.', $host);

// if there's a subdomain, and it's not 'www'... then that's the account name.
$account = (count($account) > 2 && $account[0] != 'www') ? array_shift($account) : false;



Basecamp like Urls *Permalinks*? - El Forum - 09-25-2007

[eluser]Jamongkad[/eluser]
[quote author="champs" date="1190760557"]Nothing magical or Rails-specific about it.

First, you need wildcard DNS set up, a web server willing to accept all the hostnames, and just a couple lines of PHP in your controller:

Code:
<?php
// like, such as, 'maps.example.com'
$host = strtolower($this->input->server('HTTP_HOST'));

// and now we'll get: array('maps', 'example', 'com');
$account = explode('.', $host);

// if there's a subdomain, and it's not 'www'... then that's the account name.
$account = (count($account) > 2 && $account[0] != 'www') ? array_shift($account) : false;
[/quote]

Thanks man, would this script be inserted into a function? Also would this mean that your webserver I assume allows a WildCard DNS?