0

I am looking for answer in yii.I want to create subdomain in yii.I want to do url rewrite like this.This should be applied to only one controller not every.

from

http://abcd.com/directory-1/directory-2/CotrollerName/FunctionName/Argument1/

to

http://Argument1.abcd.com/directory-1/directory-2/CotrollerName/FunctionName/

Thanks in advance !!!

Bhaskar Bhatt
  • 1,399
  • 13
  • 19

1 Answers1

0

A tricky solution will look like:

class ControllerName extends Controller {

//...

public function FunctionName($Argument1 = NULL) {

    if ($Argument1 === NULL)
        $Argument1 = preg_filter('/^([^\.]+)\.abcd\.com$/', '$1', $_SERVER['HTTP_HOST']);

    else
        $this->redirect("http://$Argument1.abc.com/.....");

    assert(!empty($Argument1));

 //.. more code here ...
}
rodrigovr
  • 454
  • 2
  • 7
  • Its not an good idea becuase i need to call this function explicitly – Bhaskar Bhatt Dec 27 '13 at 12:10
  • @BhattBhaskar can you elaborate? To apply the same solution to more functions you can create a helper or put the logic inside the base class constructor (Controller, MyController, etc) – rodrigovr Dec 27 '13 at 12:24