Domain routing possibilities in CI? |
[eluser]stevefink[/eluser]
Hi all, Super quick question. I have a few URLs that look like the following: http://www.example.com/users http://www.example.com/admin http://www.example.com/partners I understand how URI routing works on CI's internal engine in routes.php in order to be able to manipulate matters, however -- is it possible to use mod_rewrite + CI routing to have users point to say: http://users.example.com admin to http://admin.example.com .. etc? All under one CI install? if I just setup my mod_rewrite rules properly will it know which controller is responsible for handling the mapping? Thanks!
[eluser]Pascal Kriete[/eluser]
Sure it is, but it's ... iffy. The mod rewrite isn't a pretty one. This should get you started: Code: RewriteCond %{HTTP_HOST} ^(admin|users|partners).example.com$
[eluser]Sean Murphy[/eluser]
Sure! Something along these lines should work: Code: RewriteEngine on
[eluser]stevefink[/eluser]
Thanks for the reply! Would these rules have to precede the default .htaccess rules which remap all to index.php?
[eluser]Sean Murphy[/eluser]
Yes, and Code: RewriteRule ^(.*)$ /index.php?/%1/$1 [L] Code: RewriteRule ^(.*)$ index.php/$1 [L]
[eluser]stevefink[/eluser]
Sure, I'm cleaning this up currently -- my mod_rewrite is extremely rusty .. but it looks something like this thus far: Code: RewriteEngine On Thanks again. :-)
[eluser]Sean Murphy[/eluser]
I think this will do it. Code: RewriteEngine On Code: RewriteCond %{REQUEST_FILENAME} !-f Glad I could help!
[eluser]stevefink[/eluser]
Hey Sean! Thanks for the help. Unfortunately it's a no go, but I've enabled RewriteLog and going to go through it step by step to see why it's not catching the first condition set. Truly odd! It could be the way I have VirtualHosts setup, so I'll need to dig in deeper to make sure it's properly rendering %{HTTP_HOST} (the rules might be correct, or they might not.) Thanks again.
[eluser]Sean Murphy[/eluser]
Sorry, I haven't tested it. BTW, Code: RewriteRule ^(.*)$ /index.php?/%1/$1 [L] Code: RewriteRule ^(.*)$ /index.php/%1/$1 [L]
[eluser]stevefink[/eluser]
I've also tried the following, unfortunately just returns HTTP status code 500: Code: RewriteEngine On |
Welcome Guest, Not a member yet? Register Sign In |