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. :)