Somebody please tell me it’s possible to have truly clean urls like localhost/framework/mysite/about, localhost/framework/mysite/contactus, localhost/framework/mysite/search, etc.
As usual, I tried all kind of things but nothing works. I read many incomplete topics with all kind of configurations but nothing works.
I tried many things at protected/main/config.php with urlManager but one thing leads to completely white pages, others to url/index.php/something/something
Is there a step-by step tutorial or copy/paste, out-of-box configuration pack?
Sure. You need to do two things, both are on this page: URL Management
You also need to create a .htaccess file to get rid of the index.php portion of the generated URL. The details of that are further down the page. Be sure to browse the comments at the end of the page as well in case something additional matches your situation.
I followed the article, tried all kind of things with httpd.conf, .htaccess and urlManager, but still isn’t working. My biggest problem is that I found everywhere FRAGMENTS of information, not the simple, clean, focused information. For example many folks write: “turn on AllowOverride”. But there is no syntax, how to do it. Also there are 3 occurrences in that really messy config file… Ahh.
So if anybody was/is in my situation, and made the things working, please help me…
Here is what I have currently:
I’m on win7 64 bit
installed mysql
installed apache 2.2. Configured the webroot to E:/www. (I always restart the server when changed something in conf)
installed php 5.3.8. Configured the time zone in php.ini, configured php in the httpd.conf
extract yii in e:\www. If I make an app with "yiic webapp blabla", it works
Everything is working fine until this point in my learning curve. I’m stuck at making url’s fine. I always get stuff like localhost/framework/testdrive/index.php/site/index. I want instead localhost/framework/testdrive/index or localhost/framework/testdrive/contact, etc.
It is possible to have clean urls on localhost?
If yes, please tell me:
what to change to what in httpd.conf
what to write in .htaccess and where to put this file (I just saw too many configurations that is supposed to do the same thing, so I’m totally confused) I can’t see how to check if the .htaccess file is actually working (doing what is supposed to do)
what to write in the array of urlmanager: ‘urlManager’=>array( ? );
is there anything else to make/change?
I’m sorry if my post sounds childish or stupid but I simply tried so many things that simply doesn’t work.
Inside your yii application config file (default is main.php in protected/config dir) look for ‘components’ key then inside look for ‘urlManager’ key. Code following is part of my config file:
That’s exactly what I do after creating a new app and it works for me.
If you want to get rid of site/contact part of url you will propably have to edit ‘rules’ part of urlManager configuration. However it’s a huge topic and you should look for answers in manual, and CUrlManager class documentation.