Yii Framework Forum: Basic Routing Problem - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Basic Routing Problem 404 The requested url was not found on this server Rate Topic: -----

#1 User is offline   jerik 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 20-January 13

Posted 20 January 2013 - 05:07 PM

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
0

#2 User is offline   lubosdz 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 115
  • Joined: 25-July 10
  • Location:Slovakia, Bratislava

Posted 21 January 2013 - 09:34 AM

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.
Yii extension: Captcha Extended

Greatest discoveries in 22nd century will be about the gravitation. | http://www.synet.sk | http://ipdf.sk
0

#3 User is offline   jerik 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 20-January 13

Posted 21 January 2013 - 03:15 PM

View Postlubosdz, on 21 January 2013 - 09:34 AM, said:

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


Will try.

View Postlubosdz, on 21 January 2013 - 09:34 AM, said:

If that does not work, show us your .htaccess file.
.htaccess file only works with apache and must be enabled in apache configuration.


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

cheers -- jerik
0

#4 User is offline   outrage 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 313
  • Joined: 10-November 09
  • Location:Blackpool, United Kingdom

Posted 21 January 2013 - 03:27 PM

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.
0

#5 User is offline   developer! 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 110
  • Joined: 28-November 12

Posted 22 January 2013 - 10:38 AM

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>

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users