Welcome Guest, Not a member yet? Register   Sign In
Domain routing possibilities in CI?
#21

[eluser]Sean Murphy[/eluser]
You shouldn't need that RewriteCond that restricts the REQUEST_URI to letters, numbers, and forward slashes. It might even cause problems for you down the road.

Give this a shot:
Code:
RewriteEngine on

RewriteCond %{HTTP_HOST} ^([^\.]+)\.
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ index.php/users/%1/$1

RewriteCond $1 !^(index.php|images|robots.txt|js|css)
RewriteRule ^(.*)$ index.php/$1 [L]
I hope I'm helping :-)
#22

[eluser]lonka[/eluser]
Thank you for your help, but it's not working too Sad
Now I don't get error 500 but nothing happens, main page is loading not user page.

Maybe it's time for me to read a book about mod_rewrite Wink
#23

[eluser]sophistry[/eluser]
did you see this page:
http://httpd.apache.org/docs/1.3/misc/rewriteguide.html

it has a sample called virtual user hosts. perhaps it can help.
#24

[eluser]lonka[/eluser]
This one is not working too Sad

But I've try this, and this is almost working:

Code:
RewriteEngine on

RewriteCond %{HTTP_HOST} !(^www.domain.com)
RewriteCond %{HTTP_HOST} ^(www\.)?(.*).domain.com$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\. [NC]

RewriteRule ^$ index.php/user/%1 [L]

RewriteCond $1 !^(index.php|images|robots.txt|js|css)
RewriteRule ^(.*)$ index.php/$1 [L]

But this works only for http://user.domain.com I can't make it happen to get http://user.domain.com/sometingElse
I try to add $2 or something similar to RewriteRule ^$ index.php/user/%1 [L] but this is not working at all
#25

[eluser]evanwalsh[/eluser]
This topic is relevant to my interests. I hope this issue is resolved soon, as I want a similar feature.
#26

[eluser]Sean Murphy[/eluser]
Well, I guess I should have just tested this out in the first place to get it right the first time.

I set up an installation to work out the bugs, and I got it working. Hopefully it will work for you too! Here's what my .htaccess looks like:

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    
    RewriteCond %{REQUEST_URI} !^/index\.php/users/
    RewriteCond %{HTTP_HOST} ^((?!www\.)[^\.]+)\.example\.com
    RewriteRule ^(.*)$ users/%1/$1
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.

    ErrorDocument 404 /index.php
</IfModule>
#27

[eluser]lonka[/eluser]
I finally get to work with this one:

Code:
RewriteEngine on


RewriteCond   %{HTTP_HOST}                 !^www\.example\.com$

RewriteCond   %{HTTP_HOST}                 ![^.]+\.example\.com/settings/(.*)$
RewriteCond   %{REQUEST_URI}               !^/settings[^.]+$
RewriteCond   %{HTTP_HOST}                 [^.]+\.example\.com$
RewriteRule   ^(.+)                        %{HTTP_HOST}$1          [C]
RewriteRule   ([^.]+)\.example\.com(.*) index.php/profile/$1%{REQUEST_URI}


RewriteCond $1 !^(index.php|images|robots.txt|js|css|media|system)
RewriteRule ^(.*)$ index.php/$1 [L]

I have subdomain name.example.com that points to example.com/profile/name/

But on one server this works perfect, and on another with apache I got error Sad

When I try to enter for example nightmare.example.com
Log from mod rewrite:
Code:
[nightmare.example.com/sid#801439e8][rid#803ef030/initial/re#50] (1) [per-dir /var/www/vhosts/example.com/httpdocs/] internal reect with /index.php/profile/nightmare/index.php/profile/nightmare/index.php/profile/nightmare/index.php/profile/nightmare/index.php/profile/nightmare/index.php/profile/nightmare/index.php/profile/nightmare/index.php/profile/nightmare/index.php/profile/nightmare/index.php/profile/nightmare/index.php/profile/nightmare/index.php/profile/nightmare/index.php/profile/nightmare/index.php/profile/nightmare/index.php/profile/nightmare/index.php/profile/nightmare/index.php/p

it's stuck on loop, I don't know what to do with this Sad Any help?




Theme © iAndrew 2016 - Forum software by © MyBB