Basic Routing Problem

Hi,

perhaps I am to long infront of my computer. Cannot figure out what the problem is, seems that the routes does not run…

in my protected/main.php i activated the basic routes


        'urlManager'=>array(

            'urlFormat'=>'path',

            'rules'=>array(

                '<controller:\w+>/<id:\d+>'=>'<controller>/view',

                '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

                '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

            ),

        ),



When I open the url www.test.com/testdrive/testblob/1 I get the 404 Page. Normaly this should be the first route which should be run…

where is my error?

testdrive is the directory where my webapp is located.

testblob is my controller.

Database, model and controller is generated. Database table is populated. CRUD does not work anymore with the URL: www.test.com/testdrive/index.php?r=testblob. It works again if I remove the routes in the protected/main.php

Both .htaccess in my webapp contains: deny from all.

./themes/classic/views/.htaccess

./protected/.htaccess

cheers – jerik

Assuming your .htaccess file works fine, you should hide index.php file via adding "showScriptName=>false" into your main.php config file as follows:




        'urlManager'=>array(

            'urlFormat'=>'path',

            'showScriptName'=>false,

            'rules'=>array(

                '<controller:\w+>/<id:\d+>'=>'<controller>/view',

                '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

                '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

            ),

        ),

If that does not work, show us your .htaccess file.

.htaccess file only works with apache and must be enabled in apache configuration.

Will try.

as described above. one line with: deny from all.

cheers – jerik

You need a .htaccess in the root folder where index.php lives.

It should look like the following (minimal):


RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]

If you are using xampp or similar, you will probably have a folder within htdocs for your project.

In this case you should change "RewriteBase /" to "RewriteBase /project_folder/".

Remember to remove "project_folder/" when you deploy to real server.

Good luck.

im using my .htaccess like this…


<IfModule mod_rewrite.c>

	RewriteEngine On


    RewriteCond %{SERVER_NAME} ^localhost

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteRule ^(.*)$ /webapp/index.php/$1

</IfModule>