Frontend/backend Url Rewrite

Hi everybody.

First of all thanks to all developers for this great framework!

I have problem with url rewriting.

I have created frontend/backend structure for my project like this yiiframework.com/wiki/33/organize-directories-for-applications-with-front-end-and-back-end/. In config/main for both frontend and backend i have ‘urlManager’=>array(

		'urlFormat'=>'path',


                    'showScriptName'=>false,


	),

my .htaccess file looks like

RewriteEngine on

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php

Frontend part work fine mysite.com/controllerID/actionId

But backend part work this way: mysite.com/backend.php/controllerID/actionId

The question is how can i change backend.php to just backend. I need backend url like this

mysite.com/backend/controllerID/actionId

There are a lot of topics in internet like this

1)yiiframework.com/forum/index.php/topic/30971-andy-s-need-help-in-url-setting-for-frontendbackend/page__p__149132__hl__backend+url+rewrite#entry149132

2)yiiframework.com/forum/index.php/topic/33969-backend-url-structure/page__p__163447__hl__backend+url+rewrite#entry163447

3)stackoverflow.com/questions/10649266/yii-htaccess-and-urlmanager-for-separate-backend-and-frontend

But nothing work, and even simple .htaccess rule like this

RewriteRule ^backend backend.php

So if you have any ideas please reply. I will appreciate any help

P.S. Some people advise to use module for this, but it’s not appropriate for me.

What? Nobody knows?

I am not an expert when it comes to URL rewriting (Neither with Apache nor with Yii).

You said it doesn’t work when you add this line:


RewriteRule ^/backend/(.*)$ backend.php

right before this:


RewriteRule . index.php

in your .htaccess file?

I guess this is because yii is interpreting "backend" as controllerID which is infact a static string in the URL.

Can you show me/us your URL rules within the backend config? (What error does your application show anyway?)

Does it work when you create a "backend" directory and move the "backend.php" file from within the root directory into this directory? (Make sure to adjust the paths in backend.php and create a new .htaccess file with


RewriteEngine on

RewriteRule . backend.php

Try YiiBoilerplate :)

You don’t need any particular rewrite rules if you create symlinks to backend/frontend, and then keep the entire directory outside of the document root.

It works fine for me.

YiiBoilerplate

I am using YiiBoilerplate on Share Hosting

add subdomain.

admin.mysite.com point to myfolder/backend/www

urls not working.

also how do I setup??

mysite.com to point to myfolder/frontend/www

any help I will appreciate.

best regards.

go this link. you will find. ;)

http://www.yiiframework.com/wiki/155/the-directory-structure-of-the-yii-project-site/#c9444