Welcome Guest, Not a member yet? Register   Sign In
rewrite all subdomains to mainsite.com/controler/subdomain ?
#8

[eluser]Kumar Chetan sharma[/eluser]
Hey Phil,
Hope you are doing good and have never heard or read following quote.
Quote:"It is impossible to make anything fool- proof because fools are so ingenious."
I managed to do this and am laughing at my self for my foolishness. Tongue
Code:
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{REQUEST_URI} ^/Ajax(.*)
RewriteRule ^(.*)$ /index.php/Ajax/%1 [L]


#RewriteCond %{REQUEST_URI} !^(www\.)?domain\.com$ [NC] - Avoiding this will handle in my application
RewriteCond %{REQUEST_URI} !^([a-b0-9]\.)?domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ([^.]+)\.domain\.com
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/Sites/%1/$1

#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ /index.php/Sites/$1 [QSA,L]
I have missed mod rewrite tag checking. So how do u check if it works?
On ur local windows machine look for hosts file in windows folder/system32/drivers/etc and add some entries for ur subdomain.domain.com
Create virtual host for www.domain.com and also add server alias *.domain.com to this virtual host entry.
place a print_r($_SERVER) in a php file and see how it works.
Regarding Ajax, all my Ajax calls go to a url like /Ajax/mymethods/parameters not to domain.com/Ajax/mymethods/parameters.
It seemed tough initially but I found a way to handle all requests that doesn't have subdomain present using php. Looks easy now :-)


Messages In This Thread
rewrite all subdomains to mainsite.com/controler/subdomain ? - by El Forum - 08-25-2009, 12:50 PM



Theme © iAndrew 2016 - Forum software by © MyBB