Welcome Guest, Not a member yet? Register   Sign In
Wildcard subdomain points to controllers
#2

[eluser]Sarfaraz Momin[/eluser]
I have done it but to some specific subdomain names with wildcard set. Well you can still do it with a little help using .htaccess file. I want the same functionality in my existing project but I am still not to the point where I would need it. I have an example .htaccess file which might help you.

Code:
Options Includes +ExecCGI
Options +FollowSymLinks
RewriteEngine On

## Rewrite domain.com/ to welcome.domain.com/
RewriteCond %{HTTP_HOST} ^(site.com)$ [NC]
RewriteRule ^$ http://welcome.%1/ [R=301,L]

## Rewrite www.domain.com/ to welcome.domain.com/
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^$ http://welcome.%1/ [R=301,L]

## Rewrite domain.com/... to welcome.domain.com/...
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^((site)\.(com))$ [NC]
RewriteCond $1 !^(index\.php|runtime|robots\.txt|assets)
RewriteRule ^(.*)$ http://welcome.%{HTTP_HOST}/index.php/welcome%{REQUEST_URI} [QSA,L]

## Rewrite www.domain.com/... to welcome.domain.com/...
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://welcome.%1/index.php/welcome%{REQUEST_URI} [QSA,L]

## Rewrite something.domain.com/... to something.domain.com/...
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^((.+)\.)?((site)\.(com))$ [NC]
RewriteCond $1 !^(index\.php|runtime|robots\.txt|assets)
RewriteRule ^(.*)$ http://%{HTTP_HOST}/index.php/%2%{REQUEST_URI} [QSA,L]

## Fix trailing slash
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ $1/ [L]

Have a good day !!!

-Sarfaraz


Messages In This Thread
Wildcard subdomain points to controllers - by El Forum - 01-12-2009, 12:32 AM
Wildcard subdomain points to controllers - by El Forum - 01-12-2009, 02:18 AM
Wildcard subdomain points to controllers - by El Forum - 01-12-2009, 02:44 AM
Wildcard subdomain points to controllers - by El Forum - 01-12-2009, 03:03 AM
Wildcard subdomain points to controllers - by El Forum - 01-15-2009, 04:26 PM
Wildcard subdomain points to controllers - by El Forum - 03-17-2011, 11:24 AM



Theme © iAndrew 2016 - Forum software by © MyBB