0

I have this already developed project on Yii and the problem is that the modules are not accessible via URLs. So, I went to my /config/main.php to see the URL manager code. it is like:

'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>',
        ),
'caseSensitive'=>false,
    ),

EDIT: Added 'caseSensitive'=>false,

and the modules section is like

'modules'=>array(
    'api_v1',   
    'api_s1',
),

Inside modules I have folders for both and they again have controllers folder. The controller under controllers folder is ServerController.php with action functions like actionList

but when I go to access this module I type in the browser as:

http://domain-name/api_s1/server/List

but it is showing 404 error. I am not sure what else is required. Any help will be highly appreciated.

EDITED:

I have a .htaccess file in every main folder as in protected, framework and in the main folder also. All .htaccess files have only one line as deny form all

but the main .htaccess file which is on the root has this

RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php

ErrorDocument 404 /notfound.html
6
  • try 'caseSensitive' => false Commented Dec 8, 2014 at 10:28
  • no it is also not working. I am not sure, i am missing any thing? I checked and everywhere it is like this. Please see Commented Dec 8, 2014 at 10:48
  • Do you have .htaccess? Commented Dec 8, 2014 at 10:49
  • if yes then the posiblity is like you've to change List to list in LINUX since its case sensitive Commented Dec 8, 2014 at 10:50
  • I have other actions also which are not working like mostRating. so same will be applied for all? Commented Dec 8, 2014 at 10:53

4 Answers 4

1

hope this could help you

'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>',
        ),
                array('api/controller/action/', 'api/controller/action', 'caseSensitive'=>false, 'verb'=>'GET'),
                )
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for replying, but this is also not working. Seems it may be because of the htaccess file. Please see mey edited question. Thanks again.
1

Try Like

http://domain-name/index.php/api_s1/server/List

Hope you did not use .htaccess coz if you are using .htaccess you have to mention

"showScriptName" => false

in the urlManager in config/main.php to remove index.php from your URL

Edited : Again try adding these to your urlManager

    '<module:\w+>/<controller:\w+>/<action:[\w-]+>' => '<module>/<controller>/<action>',
    '<module:\w+>/<controller:\w+>' => '<module>/<controller>',
    '<module:\w+>' => '<module>',

1 Comment

Thanks for replying. I have .htaccess in main folder and also in protected and framwork folder. Updated question, please see the edited section.
0

please add this code to your .htaccess hope this could help you

RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]

Comments

0
enter code here
        .htaccess file should conatain(in Root folder of your project along with index.php)
        RewriteEngine on

        # if a directory or a file exists, use it directly
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d

        # otherwise forward it to index.php
        RewriteRule . index.php


        In main.php
        urlManager'=>array("showScriptName" => false 
                            'caseSensitive'=>false,   
                            'showScriptName'=>false,

                                       ),
    Hope this helps.



   you have also mentioned you have more than one .htaccess files so to get more clarity also refer
    http://wordpress.stackexchange.com/questions/63114/two-htaccess-files-located-in-different-directories

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.