I’ve been doing some experiments with Yii, to see if it will suit my needs. The first thing I wanted to enable was the user-friendly URLs.
What I want to achieve: to go from this URL webapproot/index.php?r=site/contact to this URL webapproot/contact.
What I’ve done:
- Created an aplication using Yiic (
php YiiRoot/framework/yiic.php webapp testdrive) - Followed the steps 2 and 6 of this link from Yii’s documentation (“User-friendly URLs” and “Hiding index.php”).
What happens is that I keep getting a 404. Any ideas of what I did wrong?
Below are some relevant excerpts to this question:
[project root]/protected/config/main.php
(...)
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
(...)
[project root]/.htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
/etc/apache2/httpd.conf
(...)
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
(...)
<Directory [path to my web projects folder]>
Options FollowSymLinks
AllowOverride All
Order deny,allow
</Directory>
(...)
From your latest comment it looks like that you need to set RewriteBase as well. As i mentioned in my first comment to your question, if you have your webserver’s DocumentRoot and your webapp in separate folders, then this problem could arise. Try this:
To debug htaccess or other server configurations, check your server error_log, for mac lion it is in the file: /var/log/apache2/error_log