I am working with Yii Framework on Apache/2.2.15 (CentOS) Server.
Following line is uncommented in /etc/httpd/conf/httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so
I can see mod_rewrite under Loaded Module when I do following
<?php phpinfo(); ?>
Yii Project Structure:
/var/www/test/
/var/www/test/index.php
/var/www/test/.htaccess
.htaccess content
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
It works fine when I do:
http://10.20.30.40/test/index.php/testcontroller/testaction
But when I do:
http://10.20.30.40/test/testcontroller/testaction
It shows following error:
Not Found
The requested URL /var/www/test/index.php was not found on this server.
Any idea?
I have the same trouble. I use Apache config alias, like:
<VirtualHost *:80>
...
Alias /project "/Users/foo/Sites/project"
...
</VirtualHost>
To solve, I use "RewriteBase" directive on .htaccess, example:
RewriteEngine on
RewriteBase /project # <---- Modify here! and remove this comment.
# 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
Source: http://www.yiiframework.com/wiki/214/url-hide-index-php/#c9725
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With