简体   繁体   中英

Receiving 404 Error in Apache - Cakephp 3 Backend on Production

Used Cakephp 3 routing to set up routes as below

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

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

This was working pretty great in Local Server and now I'm receiving 404 error on web page.

This is a fresh installation of apache with minor changes in /etc/apache2/apache2.conf

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

Tried creating a temporary new Cakephp Project which also faced similar issue my project and new temporary cake skeleton both have similar .htaccess files

inside /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>

inside /var/www/project/webroot

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

There are no errors in /var/www/apache2/error.log .

Sounds like you haven't enabled mod-rewrite in apache.

For Ubuntu:

sudo a2enmod rewrite
sudo systemctl restart apache2

Since its optional (IfModule) apache won't generate an error.

While your at it, also check if mb_string, intl and simplexml are installed

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM