Cakephp 2.X相对路径不起作用,但绝对路径起作用


Cakephp 2.x relative path is not working but absulate path is working

我有新安装的Ubuntu服务器与Apache/2.4.7,Php 5.5.9, mysql和上传我的Cakephp项目在那里,我的Cakephp版本是2.4,但我正面临一个问题,它没有找到任何css,图像,或任何其他文件定义在webroot文件夹。

http://xx.xx.xx.xxx/css/style.css(不工作,给出404错误)http://xx.xx.xx.xxx/js/min.jquery.js(不工作,给出404错误)

http://xx.xx.xx.xxx/app/webroot/css/style.css(工作)http://xx.xx.xx.xxx/app/webroot/js/min.jquery.js(工作)

选项,我已经选中了。

  • mod_rewrite正在加载

  • SERVER API是Apache而不是CGI或FASTCGI

  • 短标签打开

检查apache2.conf文件中的AllowOverride值。缺省值为none。为了工作,将其设置为"all"

检查您的虚拟主机配置是否正确。您应该在vhost的配置文件中设置AllowOverride All,如下所示:-

<VirtualHost *:80>
    ...
    <Directory "/var/www/vhosts/example.com">
        AllowOverride All
    </Directory>
</VirtualHost>