Laravel-Localization Deployment - 在此服务器上找不到请求的URL / en

I'm deploying my first laravel app with laravel-localization. Unfortunately, I am currently getting the error,

Not Found

The requested URL /en was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

I have searched the web trying to find others who had the same problem and see if they had a viable solution for me. I found at least one, but it looks like he wasn't able to solve it either. I also found this solution here, but neither idea seemed to work.

When I change (in the config/laravellocalization.php file)

'hideDefaultLocaleInURL' => false,

from False to True

'hideDefaultLocaleInURL' => true,

I can see the homepage, but only that. All other pages are redirected to the 404 error.

I have also changed the index.php file to reflect my folder structure as the public folder for this site is within a folder within the public_html folder:

require __DIR__.'/../../myapp/bootstrap/autoload.php';

...

$app = require_once __DIR__.'/../../myapp/bootstrap/app.php';

Note:1 Everything worked on my localhost. There seems to be a problem in deployment.

Note 2: As it is currently configured, the site automatically tries to load the www.mysite.com/en version, which makes me think that my changes to the index.php file were correct. Without these changes, I get the error that the page cannot load.

Note 3: Here is my current folder structure:
- /home/username
-- mostOfMyFiles
-- public_html
--- nameOfUrl
---- publicFiles

Note 4: Regarding routing, here is what I currently have in my web.php file:

<?php

    Route::group([
        'prefix' => LaravelLocalization::setLocale(),
        'middleware' => [ 'localeSessionRedirect', 'localizationRedirect' ]
        ], function()
    {
        Route::get('/', function()
        {
            return View::make('welcome');
        });

        Route::get(LaravelLocalization::transRoute('routes.about'), function() {
            return View::make('about');
        });

        Route::get(LaravelLocalization::transRoute('routes.contact', 'ContactController@getContact'), function() {
            return View::make('contact');
        });

        Route::post(LaravelLocalization::transRoute('routes.contact'),
            ['as' => 'contact', 'uses' => 'ContactController@sendMail']);

    });

I have tried adding the 'web' middleware to the group, as seen here, but this didn't solve the problem either. :(

Note: I am also hosting another site. That is why I have the public files within a folder that has the name of the URL.

Any idea what the problem could be?

I appreciate all ideas, comments, and criticism. :)

I had same problem.

After some deep research I found solution that work for me. I am a little bit noob as well with laravel deployment and I dont know why is this such a problem to deploy laravel project on shared hosting, there is literally thousand ways and every time someone said that this isn't the right way, so I dont even know what is actually right way.

I add this block of code in my "public_html/.htacces" Options -MultiViews

RewriteEngine On

# 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]

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

If someone's looking, in my case it was route:cache that caused 'Not found' exception. I completle forgot, that by default you can't use route:cache with LaravelLocalization.