0

This is my first Laravel deployment. I deployed to my test server (Ubuntu Server) and I keep getting 404 on all my pages except for the default page. When I change the default route, my current default page displayed and every other pages returns 404. Here's my deployment guide: Uploading Laravel Project onto Web Server. I used the second answer on the link as my guide. Here's my Route that works,

Route::get('dashboard','AdminController@index');
Route::get('/','AdminController@index');

But,

Route::get('users/roles','RolesController@index');
Route::post('addrole','RolesController@store');

and every other route failed, returning 404. Here's my .htaccess

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

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

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

All of this works while on my localhost while running php artisan serve

I also did a server scenario on my localhost, I mean restructure the folders to suite my deployment guide and I still got the same thing -

Not found The requested URL /tezza/public/auth/login was not found on this server.

The funny thing is that it worked before I restructured the folders in such manner.

5
  • 7
    You need to share some code and some more info on what you're trying to do. This is really a bad question.
    – Repox
    Jul 29, 2015 at 7:19
  • If you need more clarity, I'll give.
    – Peter
    Jul 29, 2015 at 7:36
  • Need to compare your Local machine vs Deploy server configs to solve this, is the stack the same? IP's / URL's? What about your .env file? So many things could be the culprit Jul 29, 2015 at 7:47
  • What type of 404 is it a server 404 or is it the laravel application returning the 404?
    – nathanmac
    Jul 29, 2015 at 7:50
  • @MatthewRath, what about the .env file? I think that's just for database config.
    – Peter
    Jul 29, 2015 at 8:12

1 Answer 1

0

I am not sure of your server setup but the below is what works for me.

In my site root folder ( on my server it is called default) I have this htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^public
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

and in my Laravel "public" folder root I have another htaccess as below:

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

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

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

Perhaps that will help?

1
  • Downvoter, if you are going to downvote please at least be civil enough to give a reason. Jul 29, 2015 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.