CodeIgniter Forums
Sub Domain Re-route - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Sub Domain Re-route (/showthread.php?tid=27137)



Sub Domain Re-route - El Forum - 02-02-2010

[eluser]jhayghost[/eluser]
Good Day,

Is it possible to re-route may sub domain? ex. my site URL is subsite.test.com and I need to re-route to test.com/subsite/index.

Thanks


Sub Domain Re-route - El Forum - 02-02-2010

[eluser]seanloving[/eluser]
try using routes or a redirect?


Sub Domain Re-route - El Forum - 02-02-2010

[eluser]brianw1975[/eluser]
i believe you need to make sure of a couple things, more research will be required of course.

a) be sure your dns sends all mysite.com and www.mysite.com to the same ip address (typical setup).
b) be sure that your webserver is set to handle those (typically most are) (ServerName mysite.com Alias www.mysite.com)
c) use a mod_rewrite rule to rewrite the subdomain

Ex -- needs to be modified:
Code:
RewriteCond %{HTTP_HOST} !^w{3}\. [NC]
RewriteCond %{REQUEST_URI} !^/userdir/ [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.com$ [NC]
RewriteRule ^.*$ /userdir/index.php?user=%1 [L]