Modules structure

I think i am missing something but i can’t seem to find it.

I have the following structure






in the config.php file i have set

'modules' => array( 'site', 'admin' ),

Now when i enter the url it redirects to the admin module, If i omit the index.php and enter it refers to the site module (the default module) instead.

Is there any reason why this would happen? Do i need to create a route? if i do then how?

Still struggling with this one.


    'urlFormat' => 'path',

    'showScriptName' => false


if this is your urlManager-config, then you should simply call

Still doesn’t work. That property just sets if you want to return index.php in the createUrl and getbaseUrl methods. I didn’t see anything else it does.

Is this something to do with apache maybe?

I am willing to pay via paypal for someone looking at this and giving me an answer.


did you have a look at the guide?

Referring to the guide it seems that you need the help of htaccess to achieve what you want.

From The Definite Guide to Yii » URL Management

Maybe this helps.


Yea i know about the htaccess file and rewrite rules. And i them setup. The problem is that if i enter it works if i do the same without the index.php it doesn’t.

Just checked and it works fine under Apache 2.2.11 (Win32)

I simply created an empty web application and added an admin module, then I created the following .htaccess file under the same directory as my index.php:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php

Now, by visiting the following 2 relative URLs I can go to the index action of the default controller of the admin module:



P.S. Forgot to mention that I also added the following under components into protected/config/main.php:


Can you tell me what’s the test2 directory is?

hmm… i’m groping in the dark.

The rewrite conditions you’ve posted here seem to work properly.

What page do you get when entering the url without index.php? Of course there are no real folders with the module id’s on root level, right?!

When i enter just i get the indexcontroller of the default module which is site. When i enter i get the index controller of the admin module. when i do i get the index controller of the default module which is site again. and no i have no admin folders in the root directory nor in the subs.

Another thing i should mention by default the index.php that loads Yii and everything else resides inside Public/index.php

my htaccess file is inside the root folder where Public directory is under the same folder i have another file index.php that includes Public/index.php not sure if i need it though but wanted to point this out.

The Yii .htaccess needs to be in the Yii application root. You also, probably, need to a add a RewriteBase to it.

I wrote a post here about this yesterday. Find that, and hopefully it will make sense.

You absolutely only need to do two things.

  1. Add:

'urlManager'=>array('urlFormat' => 'path', 'showScriptName' => false),

  1. Add .htaccess in the app root, ensuring that RewriteBase is set correctly

(required when app root is not the root directory of the Apache virtual host).

This is how my htaccess looks like and it is located in the document root where protected, public are located

# Compress JS/CSS/XML files

<IfModule mod_deflate.c>

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript


# Env

SetEnv APPLICATION_ENV development

# PHP Values

php_value include_path "Library"

php_value magic_quotes_gpc "off"

# Rewrite Engine

RewriteEngine On

RewriteBase /Public/

RewriteCond %{REQUEST_FILENAME} \.(js|ico|gif|jpg|png|css|pdf)$ [OR]

#RewriteCond %{REQUEST_FILENAME} favicon.ico$ [OR]

RewriteCond %{REQUEST_FILENAME} -s [OR]

RewriteCond %{REQUEST_FILENAME} -l [OR]

RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^.*$ - [NC,L]

RewriteRule ^.*$ index.php [NC,L]

could it be because of the rule:

RewriteRule ^.*$ - [NC,L]

RewriteBase should not have a trailing / (slash).

I tried using it with the slash and without it…same outcome.

Ok, what I’d do is strip out the .htaccess and get the basics working then start adding things back line by line.

I have the advantage of knowing I can get the basics working, of course! Which doesn’t help you, unfortunately.

If it means starting a test project from scratch, then that’s what I’d do. If you are under version control – who isn’t? – then revert and branch; you can then cherry pick the fixes into master/trunk once you’ve found the glitch.

Sounds like a good idea i will test this on a brand new working test branch and see what i can find.