• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
controller as a subdomain

#1
[eluser]x386[/eluser]
Is this possible to access controllers not only by site.com/controller and have something like this: controller.site.com?
Thanks!

#2
[eluser]meigwilym[/eluser]
Try the search - it works wonders!

Subdomaining

Mei

#3
[eluser]x386[/eluser]
This is about redirecting user. I hate redirecting! Though, in the CPanel I have options for it. Anyway to access controller without redirecting via subdoamin? like: controller.domain.com will be same as domain.com/controller

Thanks!

#4
[eluser]Colin Williams[/eluser]
I would use mod_rewrite rules to the effect of (.*).domain.com/(.*) index.php/$1/$2

#5
[eluser]x386[/eluser]
Thanks Colin! What is this mod_rewrite and how to implement it? I googled it, but I didn't find anything interesting...

#6
[eluser]Colin Williams[/eluser]
It's an Apache module that lets you rewrite URI requests. I'm not sure what Google you used Smile but my search for "mod_rewrite" returns the best resource I know of: http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html

#7
[eluser]Colin Williams[/eluser]
Also, the Router class is the ultimate controller in CI, so you could overload one or some of it's methods in your own MY_Router.php library and sniff out the subdomain before validating and routing the request

#8
[eluser]John_Betong[/eluser]
[quote author="x386" date="1224079576"]Is this possible to access controllers not only by site.com/controller and have something like this: controller.site.com?
Thanks![/quote]
 
 
I use a sub-domain on this site http://iching.justjoolz.com and for me Smile it was not easy to setup.
 
In my http://localhost I have a path to c:/www/iching/index.php and online I have http://iching.justjoolz.com/index.php
 

index.php - common to both sites
Code:
...
   define('LOCALHOST', 'localhost' === $_SERVER['SERVER_NAME']);
   ...
   ...
  $system_folder = "ci_system"; // Default - ver: 1.63
  if (LOCALHOST) {
    $system_folder = "../ci_system";
  }
  
  // http://iching.justjoolz.com
  if (strpos($_SERVER['SERVER_NAME'], 'justjoolz')) {
    $system_folder = "../ci_system"; // ver: 1.63
  }
  ...
  ...
  $application_folder = 'iching'; // http://iching.justjoolz.com/iching
  if (LOCALHOST) {
    $application_folder = '../iching';
  }

  // http://iching.johns-jokes.com
  if (strpos($_SERVER['SERVER_NAME'], 'jokes')) {
    $application_folder = 'http://iching.johns-jokes.com'; // online setting
  }
  // echo '$application_folder --> '  .$application_folder ; die;
  ...
  ...
 
Needless to say my config.php was setup with trial and error, if you want a copy let me know.
 
 


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.