Yii Framework Forum: Urlmanager Isn't Working - Yii Framework Forum

Jump to content

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

Urlmanager Isn't Working problem with url manger Rate Topic: -----

#1 User is offline   ilikeme 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 11-August 11

Posted 05 March 2013 - 07:19 AM

Hey guys,
Look, this is my config
this is .htaccess
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


<?php
return array
(
    'name' => 'Project name',
    
    'components' => array
    (
        'errorHandler' => array('errorAction'=>'site/error'),
        'request' => array('enableCsrfValidation'=>true),
        'urlManager' => array
        (
            'urlFormat' => 'path',
            'showScriptName' => false,
            'rules' => array('index.html' => 'site/index','register.html' => 'user/register')
        )
    ),
    
    'import' => array
    (
        'application.components.*',
        'application.controllers.*'
    )
);

?>



this is my controller
<?php
class SiteController extends Controller
{
    public function actionIndex()
    {
        $this->renderText(
            CHtml::link('Register', 'register.html')
        );
    }    
    public function actionError()
    {
        if(false !== ($error =  Yii::app()->errorHandler->error ))
            $this->render('error_404');
        else
            $this->render('error_500');
    }
}
?>


if I enter to register.html, it will use action site/index and no user/register
if I enter to asdadas.html for example it still use action site/index and no site/error

How do I fix it?
thansk ;)
0

#2 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 05 March 2013 - 07:48 AM

Your rules looks really weird!

What are you trying to accomplish?

Your index action also looks goofy..

Now, put back the original URL manager configuration, please.


And then set the urlSuffix property to 'html' - and that's it.

http://www.yiiframew...king-url-suffix
"Less noise - more signal"
0

#3 User is offline   ilikeme 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 11-August 11

Posted 05 March 2013 - 08:22 AM

View Postjacmoe, on 05 March 2013 - 07:48 AM, said:

Your rules looks really weird!

What are you trying to accomplish?

Your index action also looks goofy..

Now, put back the original URL manager configuration, please.


And then set the urlSuffix property to 'html' - and that's it.

http://www.yiiframew...king-url-suffix


this is the new config,
but still, i can't find the problem...
how do i fix it?
<?php
return array
(
    'name' => 'Project name',
    
    'components' => array(
        'errorHandler' => array('errorAction'=>'site/error'),
        'request' => array('enableCsrfValidation'=>true),
        'urlManager' => array(
            'urlFormat' => 'path',
            'rules' => array(
                'register.html' => 'user/register'
            )
        )
    ),
    
    'import' => array(
        'application.components.*',
        'application.controllers.*'
    )
);

?>

0

#4 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 05 March 2013 - 08:52 AM

I don't know what prevents you from reading the documentation that I so kindly linked to? ;)

Anyway...



		'urlManager'=>array(
			'urlFormat'=>'path',
            'showScriptName' => false,
            'urlSuffix' => 'html',
			'rules'=>array(
                '<action:(login|logout)>' => 'user/<action>',
                '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
			),
		),

"Less noise - more signal"
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