UrlManager Rules to subdomain in right side of url

Hi Everyone !

I need to create a blog system that allows registering subdomains.

example:

www_myweb_com/subdomain1

www_myweb_com/subdomain2

The blog should work with the controllers and actions usually like the example below:

www_myweb_com/subdomain1/controller/action

But if we access something like:

www_myweb_com/subdomain1/products

("products" is not a controller, but a kind of post) the urlmanager should target for post / all, which is the page where all posts brand products will be listed.

If we type:

www_myweb_com/subdomain1/products/ball

The system should direct to "post / single"

Ok, everything works with these rules:

‘<subdomain: [\ w -] +>’ => ‘page / index’

‘<subdomain: [\ w -] +> / <type: [\ w -] +> / <url: [\ w -] +>’ => ‘post / single’

‘<subdomain: [\ w -] +> / <type: [\ w -] +> /’ => 'post / all,

All subdomain will have an administrative area as the example below:

www_myweb_com/subdomain1/admin

www_myweb_com/subdomain2/admin

admin is AdminController and not the admin type posts page, I decided this with:

‘<subdomain: [\ w -] +> / admin’ => ‘admin / index’

The big problem I seek answers is on all URL’s that are created by Yii to update links, create and delete. All these links are printed without the subdomain and “admin” word like this:

This render a gridview of posts

www_myweb_com/subdomain1/admin/post/admin

Links to update, delete and create are printed this way:

localhost:8080/post/update?id=1 <- Its Wrong !!!!!

localhost:8080/subdomain1/admin/post/update/1 <- This is my goal !

someone help me?

thanks

Here you have an already-created blog system: http://www.yiiframework.com/extension/yii-blog/

It is yii 1.1.x, though.

Hi

Your approach is not a subdomain, that would be subdomain1_myweb_com

subdomain2_myweb_com

Your approach is a folder/homedir approach

For the approach you are taking, you could try updating the baseUrl property to be ‘homedir’, which is used in building the links.

http://www.yiiframework.com/doc-2.0/yii-web-urlmanager.html#$baseUrl-detail