我有工作的的 Yii框架的在的的Apache / 2.2.15(CentOS的)服务器的。
I am working with Yii Framework on Apache/2.2.15 (CentOS) Server.
以下行注释掉中的的 /etc/httpd/conf/httpd.conf中的
Following line is uncommented in /etc/httpd/conf/httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so
我可以看到的mod_rewrite 在加载的模块我下的时候
I can see mod_rewrite under Loaded Module when I do following
< PHP的phpinfo(); ?>
Yii的项目结构:
/var/www/test/
/var/www/test/index.php
/var/www/test/.htaccess
的.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
它工作正常,当我这样做:
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.
你知道吗?
我也有同样的麻烦。 我使用的Apache配置别名,如:
I have the same trouble. I use Apache config alias, like:
<VirtualHost *:80>
...
Alias /project "/Users/foo/Sites/project"
...
</VirtualHost>
上的.htaccess
要解决,我用的RewriteBase指令,例如:
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
来源: http://www.yiiframework.com /维基/ 214 / URL隐藏指数-PHP /#c9725