我在Apache/2.2.15 (CentOS) Server上使用Yii 框架。
以下行在/etc/httpd/conf/httpd.conf中未注释
LoadModule rewrite_module modules/mod_rewrite.so
当我执行以下操作时,我可以在Loaded Module下看到mod_rewrite
<?php phpinfo(); ?>
Yii 项目结构:
/var/www/test/
/var/www/test/index.php
/var/www/test/.htaccess
.htaccess 内容
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
当我这样做时它工作正常:
http://10.20.30.40/test/index.php/testcontroller/testaction
但是当我这样做时:
http://10.20.30.40/test/testcontroller/testaction
它显示以下错误:
Not Found
The requested URL /var/www/test/index.php was not found on this server.
任何想法?