在Apache中收到404错误-Cakephp 3生产后端

时间:2018-06-28 09:50:09

标签: php apache ubuntu cakephp apache2

使用Cakephp 3路由设置以下路由

$routes->post(
    '/auth/login/*',
    ['controller' => 'WvUser', 'action' => 'login']
);

$routes->post(
    '/auth/signup/*',
    ['controller' => 'WvUser', 'action' => 'signup']
);

这在本地服务器上运行非常好,现在我在网页上收到404错误。

这是apache的全新安装,其中/etc/apache2/apache2.conf

进行了较小的更改
<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

试图创建一个新的临时Cakephp项目,该项目也面临类似的问题,我的项目和新的临时蛋糕框架都具有相似的.htaccess文件

在/ var / www / project

内部
# Uncomment the following to prevent the httpoxy vulnerability
# See: https://httpoxy.org/
#<IfModule mod_headers.c>
#    RequestHeader unset Proxy
#</IfModule>

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    ^(\.well-known/.*)$ $1 [L]
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]
</IfModule>

在/ var / www / project / webroot内部

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

/var/www/apache2/error.log中没有错误。

1 个答案:

答案 0 :(得分:2)

听起来像您还没有在Apache中启用mod-rewrite。

对于Ubuntu:

sudo a2enmod rewrite
sudo systemctl restart apache2

由于其可选的(IfModule)Apache不会产生错误。

同时,还要检查是否安装了mb_string,intl和simplexml