Welcome Guest, Not a member yet? Register   Sign In
Subdomains as Userpages / Profilepages
#1

[eluser]Unknown[/eluser]
I'm searching for a way to make subdomains ussable for
profilepages of users.

Ofcourse I need a wildcard in my DNS and Apache config, which is
already done and working.

Because I want to keep this way of subdomains flexible, I don't want
to use a .htaccess file so I need to do something with a route that
recognizes the subdomain and does something magic.

Something like this could work I think:

$usernamehost = explode(’.', $_SERVER['HTTP_HOST'], 2);

I have found a CI example that does explain it, but not in detail if you ask me. SO I'm confused how to use this. The blog itself also redirect to this forum, but still I can't find the right solution.

http://andy.sinaptix.com/2007/08/22/user...deigniter/

Has anyone done this already ?
#2

[eluser]bretticus[/eluser]
I read the post. It's actually pretty clear if you ask me (more so than I was expecting to be.) Maybe I can clear it up a little more:

Code:
//from those forum entry, I’ve made final modification to the config.php file :
$config['base_url'] = 'http://'.$_SERVER["HTTP_HOST"];
// provide easy to access variables for the rest of the application
$usernamehost = explode('.', $_SERVER['HTTP_HOST'], 2);
$config['tld_base_url'] = $usernamehost[1]; //contains "domain.com"
$config['user_base_url'] = $usernamehost[0]; //contains "sub"

...Means put that in your application/config/config.php file. ($config['base_url'] is already there. it needs to be modified per example above.)

$config['user_base_url'] gives you the user name at all times. Either pass this config item (read config class in manual) from your controller to your model that gets user data or get it from within that model.




Theme © iAndrew 2016 - Forum software by © MyBB