[solved] how can I make beautiful.urls.for/my-site

Guys - help needed!

I’m creating a site that will have a number of law firms as clients. Each firm will have cases. I’d like to be able to have URLs like this:

<firm-name>.mydomain.com/<case-name>/<controller>/<action>

I’d then like to be able to access the case-name and firm-name in the controller as if they were $_GET params. I guess the URL should remap to:

www.mydomain.com/index.php?r=<controller>/<action>&firm=<firm-name>&case=<case-name>

I’ve got a reasonable grasp of the CUrlManager component, but I don’t know how to interact with subdomains - I’ve never used them before. Can I even create them dynamically?

Since 1.0.11 you can use parameterized host names in your url rules. They need to start with ‘http://’ or ‘https://’. So for your case a rule like this should work:


array(

    'http://<firm:\w+>.mydomain.com/<case:\w+>/<_c:(your|available|controllers)>/<_a:(your|available|actions>' => '<_c>/<_a>',

);



For better safety you should supply the list of available controller/action Ids in the rules i think. If you don’t care you could also use <_c:\w+> and <_a:\w+> in the pattern.

Nice one, that works perfectly.


array(

    'http://<firm:\w+>.mydomain.com/<case:\w+>/<_c:(your|available|controllers)>/<_a:(your|available|actions>' => '<_c>/<_a>',

);



It converts a domain www.mysite.com into: www.firm.domain.com?