Welcome Guest, Not a member yet? Register   Sign In
help with mod rewrite and CI
#1

[eluser]Waiel[/eluser]
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

Code:
RewriteEngine on
##hide Index.php
RewriteCond $1 !^(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 $1 !^(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
#2

[eluser]Waiel[/eluser]
Found the sloution and it worked fine ..

Code:
RewriteEngine on
RewriteCond $1 !^(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
#3

[eluser]mypcbox[/eluser]
Please forgive my ignorance with rewrite rules but when you say:

Quote: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.
#4

[eluser]Waiel[/eluser]
yes that what i mean
basicly this will help you

Code:
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




Theme © iAndrew 2016 - Forum software by © MyBB