Pretty URLS in Yii

Pretty URLS are easy to read and helpful in SEO.

To take the benefits of pretty urls in Yii, please follow the below guidelines:

1) Open “main.php” configuration file of Yii.

It is located under your_application/protected/config/ folder

2) Paste the below lines in  “components” array

‘urlManager’=>array(‘urlFormat’=>’path’, ‘showScriptName’=>false,),

3) Create “.htaccess” file in your application where “index.php” file is located

Add following lines to “.htaccess” file :

Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

4) If your application is not showing pretty urls, then check whether your Apache configuration file i.e httpd.conf has the following module :

LoadModule rewrite_module modules/mod_rewrite.so

Remove “;” semicolon preceding the above line.

Save and restart the Apache server

Advertisements

4 Comments »

  1. 1
    Gobi Says:

    hi Nagesh,

    its nice to hear yii that you are working stuffs in it.

    im in startup now in yii jus did installed basic site n also blog . after that i have no idea to move further . if you wish can you give up ur hands to move further in yii … 🙂

    thanks in advance,
    Gobi, Chennai, India .

  2. 2
    Gobi Says:

    hi Nagesh,

    its nice to hear yii that you are working stuffs in it.

    im in startup now in yii jus did installed basic site n also blog . after that i have no idea to move further . if you wish can you give up ur hands to move further in yii … 🙂

    thanks in advance,
    Gobi

    • 3
      Komarashetty Venkat Nageshrao Says:

      Thanks for your comment. Nice to hear that you are using yii. May I know how can i help u?

  3. 4
    Aldo Says:

    Muchas gracias por la información!


RSS Feed for this entry

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: