Showing posts with label Yii. Show all posts
Showing posts with label Yii. Show all posts

January 23, 2014

Yii remove index.php from URL and SEO URL tips


This one is using for removing index.php and also remove site portion from URL.

I am trying to remove index.php from the URL string for so many times. Finally i got some cases in which i want to share with you guys.


Verify mod_rewrite is enabled in your server you can check it to load php.ini file.

Just copied following code and paste into urlManager in main.php
Here's what I put under components file 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>',
'/'=>'site/index',
'blog'=>'post/index',
'<view:(about)>'=>'site/page',
'contact'=>'site/contact',
'login'=>'site/login',
),
//'urlSuffix'=>'.html',
),

Also,
You can make your own rule to your web page need:
Here, i have changed site/login to login and site/contact to contact.
Also , post/index to blog as you can see in the rules array.

Hope this is one helps you in many ways.





December 30, 2013

Yii Framework Migration Tips

Yii Framework Migrations - based on tool(1.1.14) 

Straight Serial

1) Modify config.php under protected/config. Also change in main.php same directory.

2) Come to Command Prompt. (Type "cmd" in run menu)

3) Go to the project directory . e.g. :D\wamp\www\phpproject\protected

Type "php.exe yiic migrate create san"

where, "san" is the migrate php file

It will ask you to confirm to create migration or not.

Press Y to confirm.

New migration created successfully. The file would save in protected/migrate directory. 

Executing the migration.
 Go to the project directory . e.g. :D\wamp\www\phpproject\protected

Type "php.exe yiic migrate".

Migration file will restore your db in localhost server.