![]() |
subdomains, htaccess, dns wildcards and codeignitor all on the fly - 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: subdomains, htaccess, dns wildcards and codeignitor all on the fly (/showthread.php?tid=25678) |
subdomains, htaccess, dns wildcards and codeignitor all on the fly - El Forum - 12-20-2009 [eluser]bugboy[/eluser] Hi all I'm hoping someone can help me with this challenge I have. I'm attempting to create a service that when users sign up to it creates a subdomain for them on the fly. for example: user.domain.com Now I have a wildcard DNS set up on my server so I know it can be done using a .htaccess file to redirect a subdomain to a folder but what i'd like it to do is to redirect to a controller in codeignitor. This is what I have at the moment .htaccess wise. But for some reasons its not routing right. Code: RewriteEngine On How do i access the data from the rerouted url Any help as i'm not sure i'm on the right track i'm getting a lot of 500 errors if i do this: http://welcome.domain.com/hello subdomains, htaccess, dns wildcards and codeignitor all on the fly - El Forum - 12-20-2009 [eluser]Colin Williams[/eluser] Is the rewrite even necessary? The domain will resolve without it, right? And you don't need to duplicate the subdomain in the path, because, well, it's sitting right there in the URI. I think you're getting a 500 because your rules look like they'll hit an infinite loop. subdomains, htaccess, dns wildcards and codeignitor all on the fly - El Forum - 12-21-2009 [eluser]bugboy[/eluser] you know i think your right. All domains will resolve straight away due to the wildcard dns. Oh this is great i think i was making it more difficult then i needed. I'll just use the url. Cheers for making me see sense. subdomains, htaccess, dns wildcards and codeignitor all on the fly - El Forum - 12-22-2009 [eluser]wekadesign[/eluser] i have setting config.php and fill with this $config['base_url'] = 'http://'.$_SERVER["HTTP_HOST"].'/'; and when i access all subdomain like http://myallsubdomain.maindomain.com it`s will route to one controller on CI subdomains, htaccess, dns wildcards and codeignitor all on the fly - El Forum - 12-22-2009 [eluser]wekadesign[/eluser] its my .htaccess file RewriteEngine On RewriteBase / RewriteRule ^(.*)$ index.php/$1 [L] subdomains, htaccess, dns wildcards and codeignitor all on the fly - El Forum - 01-22-2010 [eluser]A83[/eluser] I'm doing the same thing. The user gets username.domain.com as it's url. I've set up DNS, .htaccess and get sub domains to go to a different controller than the top domain. I've got routing that looks like this: Code: if($_SERVER['HTTP_HOST'] == "www.domain.com" || $_SERVER['HTTP_HOST'] == "domain.com") How do I send the user as a "variable" to the sub controller? Thanks in advance! |