Welcome Guest, Not a member yet? Register   Sign In
Redirect a subdomain to a controller
#1

[eluser]Unknown[/eluser]
I've set up my server to accept wildcard entries as subdomains using the VirtualHost directive. Now I want my CI app to handle all subdomain requests on a particular controller e.g.

sub1.mysite.com => group/sub1
sub2.mysite.com => group/sub2

where 'group' is the controller.

I have set up my route like so...

Code:
$route['group/(:any)'] = 'group/group_page/$1';

but now I am stuck on the htaccess part (I think). Where do I go from here?
#2

[eluser]Adamcbrz[/eluser]
[quote author="KevBrad" date="1255044014"]I've set up my server to accept wildcard entries as subdomains using the VirtualHost directive. Now I want my CI app to handle all subdomain requests on a particular controller e.g.

sub1.mysite.com => group/sub1
sub2.mysite.com => group/sub2

where 'group' is the controller.

I have set up my route like so...

Code:
$route['group/(:any)'] = 'group/group_page/$1';

but now I am stuck on the htaccess part (I think). Where do I go from here?[/quote]

I haven't tested this but i think the following would work for .htaccess
Code:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
rewriteCond %{HTTP_HOST} ^sub1\.mysite\.com [NC]
rewriteRule ^(.*)$ /group/sub1/$1 [QSA,NC,L]




Theme © iAndrew 2016 - Forum software by © MyBB