Laravel Routes Testing Error 404

Website URL

http://table.great-site.net/test

Error Message

404

Other Information

routes/web.php

use Illuminate\Support\Facades\Route;
Route::get(‘/test’, function () {
return response()->json([‘message’ => ‘Routes work’]);
});

===========

Hi acustic,

Laravel defaults the web root to be in public/ but in free hosting it’s always htdocs/. You need to implement a .htaccess file to redirect all traffic to public/index.php.

Cheers!

6 Likes

To add to what @anon95807532 said, this is an example of such .htaccess code:

Other methods do exist.

6 Likes

I wrote in the .htaccess

RewriteEngine On
RewriteRule (.*) /public/$1 [L]

and now the server returns index.php.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.