Maybe it looks simple, but some time ago I need some time to find a solution of this case. I finally got it, and I want to share that I also experienced such cases. So that it can make reference.
Neither let us do the steps:
change this setting :
#LoadModule rewrite_module modules/mod_rewrite.so
to be
LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]
if above does not work try with this:
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
www - protected - index.php - .htaccess
'urlManager'=>array( 'urlFormat'=>'path', 'showScriptName'=>false, 'caseSensitive'=>false, ),
For reference material I managed to do in my personal website (check my profile).
NB: This for hide index.php
Total 13 comments
It works all over except in CMenu items. CMenu items shows index.php in Url.
I don't know how fix it.
Also, if you're on a virtual directory (e.g. using
on your apache configuration) you MUST use a
statement on your .htaccess file, other than the rewrite won't work again.
Thanks for this great article
I just tried it but I fail first because I forget and put this variables
inside the array of the rules :)
I just a newbie with YII :) so I'm just confused
Thank you again
Hello, May you take a look on my yii topic
yiiframework.com/forum/index.php/topic/33491-user-friendly-urls/page__p__161195__fromsearch__1#entry161195
I have made what is required but it does not work. I dont understand why.
Thank you!
As thiromi said, make sure that you change the "AllowOverride" flag to "All"
I am using WAMP, it works after i include the line:
RewriteBase PROJECTNAME
in file [.htaccess]
thanks for article.
Thank you! It works! :D
To get mod_rewrite working not only mod_rewrite must be installed, but also check in the Apache directory config (/etc/apache2/sites-enabled/000-default on Ubuntu installed via apt-get) if the rule "AllowOverride None" exists in your project's directory config. If so, change it to "AllowOverride All". I have spent hours because of this thing, so it's my tip to get things working.
thank you, you are right. This can not be run if not in the main config settings.
Set main.php in your yii configuration, at component : [php] 'urlManager'=>array( 'urlFormat'=>'path', 'showScriptName'=>false, 'caseSensitive'=>false, ),Thanx for pretty formatting, now it's clearer what you want to achieve. Yet, the question is: What is the benefit over setting the built-in paramater for urlManager in configuration:
'showScriptName'=>false,
http://www.yiiframework.com/doc/api/1.1/CUrlManager#showScriptName-detail Cheer, Lubos
this article to hide index.php url: for example:
to be
Hi, your article is a bit unclear about what is the goal you are trying to reach? Perhaps 1-2 examples would make things clearer:-) Also what is the final content of .htaccess file? (you may want to put it into solid code block pretty formatted). Cheers Lubos
Excellent article on how mod_rewrite works - http://www.workingwith.me.uk/articles/scripting/mod_rewrite#writeComment
From the site - "mod_rewrite is used for rewriting a URL at the server level, giving the user output for that final page. So, for example, a user may ask for http://www.somesite.com/widgets/blue/, but will really be given http://www.somesite.com/widgets.php?colour=blue by the server."
Leave a comment
Please login to leave your comment.