Htaccess .. SEO Friendly Url

2 followers

hello firend if u need a SEO friendly URL

Go to ur .htaccess file in and use this code carefully

RewriteEngine on
RewriteBase /
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php)
 
# otherwise forward it to index.php
RewriteRule ^(.+)$ yourproject/index.php?$1 [PT,L,QSA]

this code will remove the index.php in the URL For eg. www.example.com/index.php/yourview to www.example.com/yourview

RewriteRule ^(.+)$ index.php?$1 [PT,L,QSA] (if ur in root use this line "RewriteRule ^(.+)$ index.php?$1 [PT,L,QSA]" instead of "RewriteRule ^(.+)$ yourproject/index.php?$1 [PT,L,QSA]" )

Total 4 comments

#11508 report it
bryglen at 2013/01/17 10:16am
manoj20

this is already provided by yii. please the docs of wiki.

#11184 report it
metalguardian at 2012/12/24 06:06am
thanks

thanks for this article. can you add configuration to nginx?

2karminski

but guide can not help to remove index.php in url. check your sites - all links available with index.php in it.

#10956 report it
Manoj M at 2012/12/06 08:13am
Thanks

this is for those who work with .htaccess

#10955 report it
karminski at 2012/12/06 06:10am
This post is meaningless ...

I'm sorry, my friend, by that post is meaningless. Yii guide contains sufficient information about URL Management.

Leave a comment

Please to leave your comment.

Write new article
  • Written by: Manoj M
  • Category: Tutorials
  • Yii Version: all
  • Votes: +2 / -7
  • Viewed: 12,033 times
  • Created on: Dec 5, 2012
  • Last updated: Jul 22, 2014
  • Tags: yii