EllisLab text mark
Advanced Search
     
help with mod rewrite and CI
Posted: 05 July 2007 11:12 AM   [ Ignore ]
Joined: 2007-05-04
28 posts

Hi.
i finished my first site based on CI FW and i really love how easy it made my life to finish such project.

The only problem im facing is with the virtual sub domains for the members in the site.

in order to have this i use mod_Rewrite to enable that.
my domain name is something like   my-site.com and i made my Mod_rewrite to be like this

RewriteEngine on
##hide Index.php 
RewriteCond $!^(index\.php|public|tmp|images|css|javascript|upload|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

##Subdomains redirect
RewriteCond %{HTTP_HOST} ^((.+)\.)?((my-site)\.(com))$ [NC]
RewriteCond 
$!^(index\.php|public|tmp|images|css|www|javascript|upload|robots\.txt)
RewriteRule ^(.*)$ http://%{HTTP_HOST}/index.php/groups/%1 [QSA,L] 

basicly each subdomain represents a group and it should point it to http://www.my-site.com/index.php/groups/groupname ..

so if the groupname is Markgroup it should point to http://www.my-site.com/index.php/groups/markgroup


the rewrite code i wrote doesn’t work
it will only point to the main page and nothing else ..

Anyone can tell me what i’m doing wrong ..?


Thanks

 
Posted: 05 July 2007 07:28 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2007-05-04
28 posts

Found the sloution and it worked fine ..

RewriteEngine on
RewriteCond 
$!^(index\.php|public|tmp|images|css|javascript|upload|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1


RewriteCond 
%{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} !^(www\.)?my-site\.com[NC]
RewriteCond 
%{HTTP_HOST} ^(www\.)?([^\.]+)\.my-site\.com[NC]
RewriteRule 
^(.*)$ /index.php/groups/%2 [QSA,L] 

hope it will help someone someday smile

 
Posted: 31 August 2007 09:03 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2006-04-21
2 posts

Please forgive my ignorance with rewrite rules but when you say:

The only problem im facing is with the virtual sub domains for the members in the site.

will this take care of the issue like user1.my-site.com, user2.my-site.com, etc. 

I am also in a position where I need to handle virtual sub domains I just wanted to be sure this would work. 

Thanks in advance.

 
Posted: 31 August 2007 11:40 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Joined: 2007-05-04
28 posts

yes that what i mean
basicly this will help you

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} !^(www\.)?my-site\.com[NC]
RewriteCond 
%{HTTP_HOST} ^(www\.)?([^\.]+)\.my-site\.com[NC]
RewriteRule 
^(.*)$ /index.php/groups/%2 [QSA,L] 

in that
if you set anything beside www it will redirect to /index.php/group/Nameofsubdomain

for example

mydomain.mysite.com will be redirected to http://www.mysite.com/index.php/group/mydomain