We can configure the URL in Yii php Framework which helps to generate SEO friendly url. We can do it by using urlManager in our yii application. In this tutorial we are going to use Yii2.0. To make seo friendly url configure the file named web.php in config folder:
- open web.php file in config folder.
- add the following code under components
"urlManager"=>[
"class"=>"yii\web\UrlManager",
"enablePrettyUrl"=>TRUE,
"showScriptName"=>FALSE,
"rules"=>[
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
]
],
- create .htaccess file under the root directory and wite the following copy code:
<IfModule mod_rewrite.c>
# Turn on URL rewriting
RewriteEngine On
RewriteBase /project-root/web/
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
Thanks for your help. Looking forward for your next blog. Just wanted to know about everything in detail.
ReplyDeleteRegards:
http://www.sellingonlinetoday.com