Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jwillz21's avatar

404 error: when deploying (Sorry, the page you are looking for could not be found.)

I'm getting a 404 error when I'm deploying my project on a live server. I'm getting a laravel page saying Sorry, the page you are looking for could not be found. so I know it is reaching my project.

I ran php artisan config:cache and php artisan route:cache to register my routes and cache, but it still isn't changing. not really sure why I'm getting this error. My document root in my vhost is set to my public folder as well.

Steps I took to deploy

  1. cloned my project from git
  2. changed branch to my develop branch
  3. made my permissions for the project 777 (I know its wrong by I just wanted to get it to deploy and see if it had bugs)
  4. pointed my vhost to project/public 5 .added .env (was using it in previous deployment)
  5. composer install
  6. composer update
  7. php artisan config:cache
  8. php artisan route:cache

vhost

<IfModule mod_ssl.c>
   <VirtualHost *:443>
      DocumentRoot /var/www/html/API/public
      #DocumentRoot /var/www/API/public/

      ServerName api.app.io
      ServerAlias api.app.io
      ErrorLog ${APACHE_LOG_DIR}/api-error.log
      CustomLog ${APACHE_LOG_DIR}/api-access.log combined

         <Directory "/var/www/API/public">
            #Options +Includes
            #Options +FollowSymLinks -Indexes
            Options All
            AllowOverride All
            Require all granted

         </Directory>

      SSLCertificateFile /etc/letsencrypt/live/api.app.io/cert.pem
      SSLCertificateKeyFile /etc/letsencrypt/live/api.app.io/privkey.pem
      Include /etc/letsencrypt/options-ssl-apache.conf
      SSLCertificateChainFile /etc/letsencrypt/live/api.app.io/chain.pem
   </VirtualHost>
</IfModule>

.htaccess

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    # RewriteCond %{HTTP:Authorization} .
    # RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Handles JWT middleware
    RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
</IfModule>

If I run php artisan route:list it lists all my routes in my routes/api.php file for isntance one listed it GET api/categories but if I run that in the browser or postman I get back a 404 not found error.

0 likes
1 reply

Please or to participate in this conversation.