Can I rename customer in the url to admin?

SenG

New Member
We have customized the scripts in a such a way that would let customers act as admin. So I prefer to call customers as admins. Is there a way to change the app name, "customer" to admin?
 
Last edited:
@twisted1919 - I badly need to rename the url from /customer to /admin for my assignment to complete. I already spent hours (or days) to figure out the change, but still in vain. If you can help me on the rename part, I'd be great. I' m sharing what I have tried so far.

I noticed in all the view files, you have used $this->createUrl() so adjusting the baseUrl would yield the desire results. I tried from htaccess

In .htaccess,

Code:
    RewriteCond %{REQUEST_URI} ^/admin(/.*)?$
    RewriteRule ^admin/(.*)$ /customer/$1  [L]

When I tried to change the baseUrl from apps/customer/config/main.php, everything broke. It appears that you attached AppsBehavior that takes care of Url. There, I tried modifying getBaseUrl() method, but that doesn't work either. Where you actually configure the baseUrl so the url gets the baseUrl relative to their apps?

Or, shall I clone customer directory into admin and change all references from 'customer' to admin?
 
@SenG - the url is generated based on the entry script (index.php) so it will always contain /customer/ in it, regardless of what you do in .htaccess

Try to copy the /customer folder (NOT the one from the apps folder, but the one from the document root) and rename the copy into admin.
This should make sure all links will work just fine, except the ones generated with the 'customer' wording in them. Luckly those are not that many and for them you can have a rewrite rules in htaccess to redirect whatever comes into /customer to /admin.
 
Thank you for the prompt response. Actually, I succeeded in manipulating .htaccess (one in the project root) to resolve all requests to /admin to /customer directory and it works great! The problem is all the subsequent URLs after the landing page still gets generated with /customer/. Thankfully, you generated all URLs with createUrl(), so I tried to adjust the basePath of my custom config, but it broke all assets / css.

I tried to copy the customer directory too, but it broke in many places as well. Changing URLs is pretty straightforward in Yii apps, but it seems that you have extended and customized the request component so the documented Yii code didn't work.

I believe customer, admin, console & frontend are different Yii apps bootstraped via respective conf files. If we adjust baseUrl, they would change the way it generates the Url when we give $this->createUrl(). If I'm right, can you tell me where I have modify the code to adjust the baseUrl?
 
I believe customer, admin, console & frontend are different Yii apps bootstraped via respective conf files. If we adjust baseUrl, they would change the way it generates the Url when we give $this->createUrl().
Yes, you are right about this, they are all separate yii apps and are connected via the common app.

so I tried to adjust the basePath of my custom config, but it broke all assets / css.
You shouldn't do that :P
http://www.yiiframework.com/doc/api/1.1/CController#createUrl-detail
http://www.yiiframework.com/doc/api/1.1/CApplication#createUrl-detail
They both call http://www.yiiframework.com/doc/api/1.1/CUrlManager#createUrl-detail

So, have you tried to set the http://www.yiiframework.com/doc/api/1.1/CUrlManager#baseUrl-detail property for the url manager component?
In your apps/customer/config/main-custom.php file like:
PHP:
[...]
'urlManager' => array(
   'baseUrl' => 'http://www.domain.com/admin'
)
[...]
Not sure if that will do it, but worth the try.
 
Back
Top