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 In config/main for both frontend and backend i have ‘urlManager’=>array(




my .htaccess file looks like

RewriteEngine on

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php

Frontend part work fine

But backend part work this way:

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

There are a lot of topics in internet like this




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.


I am using YiiBoilerplate on Share Hosting

add subdomain. point to myfolder/backend/www

urls not working.

also how do I setup?? to point to myfolder/frontend/www

any help I will appreciate.

best regards.

go this link. you will find. ;)