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

edgreenberg's avatar

urls don't fire routes, but return 404

I have a Centos/apache server with laravel app installed in /var/www/html/centraladmin. My document root is /var/www/html/centraladmin/public.

When I point the browser to the top URL/ I properly get the route for /

When I point the browser to /foo, I don't match the 'foo' route, but instead log a 404. The error log shows

[Thu Jul 19 14:58:56.638606 2018] [core:info] [pid 8195] [client 127.0.0.1:34800] AH00128: File does not exist: /var/www/html/centraladmin/public/foo, referer: https://local.centraladmin.com/

Other servers that have this code checked out work fine.

I've reviewed httpd.conf, .env, permissions, everything I can think of.

One problem I have is that I don't understand why it SHOULD work. There is no .htaccess file. The Request Lifecycle doc says "The entry point for all requests to a Laravel application is the public/index.php file. All requests are directed to this file by your web server (Apache / Nginx) configuration." There doesn't seem to be anything in my working installations that would cause a rewrite to occur, although in all other servers, it always has worked.

Any suggestions welcome.

Ed Greenberg

0 likes
5 replies
Tray2's avatar

Check that mod_rewrite is enabled in apache.

Tray2's avatar

Do you have an .htaccess in your public folder that looks like this?

<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]
</IfModule>
Cronix's avatar

One problem I have is that I don't understand why it SHOULD work. There is no .htaccess file.

So you don't have the default .htaccess in the /public dir that laravel ships with?

https://github.com/laravel/laravel/blob/master/public/.htaccess

What does your httpd.conf have for this site? You don't actually need and htaccess file, but the rewrite rules that are in the htaccess file would need to be in your httpd.conf for that vhost.

edgreenberg's avatar

Thanks for pointing me in the correct direction. I did have the .htaccess file. (I didn't know that I had it, so now I understand why is SHOULD work.

What I didn't have was the proper AllowOverride All directive in a Directory tag inside my httpd.conf. Now I do.

Things seem to be working now.

Hope to meet some of y'all at Laracon next week.

Ed

Please or to participate in this conversation.