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

spacedog4's avatar

Page loads but in network gets 404

Someone has seen something like this? Only in server side, I load my admin page, it shows up normaly, but in network it's receiving a 404, I cant login, cause the route for login post also receive a 404, no php errors and on local it works perfect

http://prntscr.com/lektuo

The site http://engenhariamrc.com.br/admin

0 likes
32 replies
D9705996's avatar

Have you changed you APP_URL in your production .env to match your domain name as it defaults as below

APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost

Make sure you also set APP_ENV TO production and APP_DEBUG to false.

If you have cached yiur config you will need to run php artisan config:cache to update the cached settings

1 like
Snapey's avatar

Thats odd.. a 404 but the page loads?

spacedog4's avatar

@Snapey So weird, I never saw this, I updated my question so you can visit the page and see by yourself

D9705996's avatar

Can you share the code from the function that loads yours admin/login view. It sounds like there might be something in the code thats returning a 404 instead of a 200

munazzil's avatar

@spacedog4

Can you try in your local server in your CMD as like below and show the error

    php artisan serve
spacedog4's avatar

@D9705996 actually, it's not necessary, I emptied the file, leting just a "test" and it keep geting 404

D9705996's avatar

Is there any entries in you apache logs that might help identify why a 404 instead of 200 is being returned?

spacedog4's avatar

@D9705996 I'm hosting my site on king.host I'll ask for a apache log, cause I just have access to a php errors file that is empty

spacedog4's avatar

That is the response about the apache log from my server

[Wed Nov 07 17:07:24.503040 2018] [core:info] [pid 116542:tid 140133659547392] [client 2804:14d:bad4:9daf:40d7:3cc0:9fd3:fbd:51362] AH00128: File does not exist: /home/engenhariamrc/www/admin/login

www.engenhariamrc.com.br 2804:14d:bad4:9daf:40d7:3cc0:9fd3:fbd - - [07/Nov/2018:17:19:05 -0200] "GET /admin/login HTTP/1.1" 404 1134 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:63.0) Gecko/20100101 Firefox/63.0" 51956

Cronix's avatar

Have you tried php artisan config:clear and php artisan view:clear?

D9705996's avatar

Looking at your file path (not url) I would expect to see a public folder (between www and admin)

/home/engenhariamrc/www/admin/login

How did you deploy your application?

Cronix's avatar

also clear your browser cache when making url changes.

spacedog4's avatar

@d9705996 It has a public folder after www

http://prntscr.com/lfusf4

And here is my www/.htaccess

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>
 
    RewriteEngine on
 
    RewriteCond %{REQUEST_FILENAME} -d [OR]
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^ ^ [N]
 
    RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
    RewriteRule ^(.*)$ public/
 
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
 
</IfModule>

And another one inside public folder www/public/.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]
</IfModule>
Snapey's avatar

You should not have a .htaccess file in www/ because all requests should be landing in the www/public folder if this is not the case then reset your document root to the public folder.

Otherwise.... you're on your own!

1 like
spacedog4's avatar

@snapey Wait, but if www is the default folder for the hosting, how can I make it become www/public without using .htaccess? I saw many people moving the content from public to the root, but that's not corret, I thought that the .htaccess way was the correct, I acctually made a few sites this way

spacedog4's avatar

My hosting don't allow me to change the root folder, it is www, It was too hard to find a server that has php 7.2, now I need to find one that I can change the root folder with a good price

scottplunkett's avatar

The only folder that should be on the public-side is the public folder of Laravel. Everything else should be out of the document root of your web server.

Who is your hosting provider? Maybe I can see some information on what they use and guide you from that?

1 like
scottplunkett's avatar

@SPACEDOG4 - You would be correct on that assumption. :)

If they support Laravel maybe a good place to ask for some help would be the web host's support channels. Without knowing the underlying structure I cannot say for certain what actions to take.

1 like
Snapey's avatar

See if you can load any files into /home/engenhariamrc/

If you can, put your laravel framework there, and put the contents of Laravel's public folder into www

www then plays the role of your public folder

Then you don't need to change any files or play tricks with .htaccess - all can be standard.

1 like
arthvrian's avatar

as @snapey said:

put your files outside your public folder www

right now you can go to

http://engenhariamrc.com.br/admin/login -> 404 http://engenhariamrc.com.br/public/admin/login -> 200

Upon entering www, www/.htaccess 'process' the request and sends it to www/public/.htaccess which sends it to www/public/index.php, which processes the request

try removing/renaming www/.htaccess and hit the two links before (first one must be not working anymore)

1 like
spacedog4's avatar

Oh finallyyy, the three of you were corrects, I needed to put the content of public into www and create another folder outside, THANK YOU GUYS SO MUCH for helping me, I'm going to give the best answer to the first one that solved my problem.

I love this community

1 like
Next

Please or to participate in this conversation.