URL and .htaccess

I want clear url for SEO point of view. i have changed and added the following .htaccess code and configuration in main.php

//.htaccess:

======================

IndexIgnore /

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php

=================================

//main.php

====================================

‘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>',


            ),


        ),

=====================================

this issue is i have a number of links in my application with ?r=controller/method how can i handle it with .htaccess without changing all the URLs format in my application.

Thanks in advance

Once you changed CUrlManager::$urlFormat to ‘path’, all your URLs should automatically take the path form (example.com/controller/action) - provided that you used Yii::app()->createUrl() method to build your URLs. If you hardcoded URLs, then you should replace them all with a call to createUrl() method. This may be a bit more work, but it is the proper way of doing things.

So if you have something like this in your view:


<a href='index.php?r=site/login'>Login</a>

You should replace it with:




echo CHtml::link('Login', array('site/index'));



Or, if you don’t want to create an <a> tag, just call:




Yii::app()->createUrl('site/index');



Thank You very much

Can you help me in the following regard:

i have a module like this:

http://localhost/verifynder/user/registration/group_id/2

i the group_id=2

when i called this url Error 404 occurs

for the life of me, i cannot strip index.php from the URL. No idea why. I have it now that domain.com/index.php/site/login works, but obviously that’s the ugliest thing in the world. my .htaccess looks the same as yours. in the same dir was my index.php where i create my yii app.

Any tips? :confused: