title: Laravel Sometimes Showing 404 not found page
body: <p>I'm working on <strong>Laravel 8</strong> and i have a problem <strong>sometimes</strong> when I <em>refresh page or open it direct</em> by link showing</p>
  <p><strong>Not found page 404 error</strong> , i tried  lots of solutions on internet but no solution working with me .</p>
  <p>Another note : it's also showing for me when i send request using <strong>ajax</strong> it's the most time showed for me .</p>
  <p>My <strong>web.php</strong> :</p>
  <pre><code>&lt;?php
  
  use App\Http\Middleware\AdminAuth;
  use Illuminate\Support\Facades\App;
  use Illuminate\Support\Facades\Route;
  
  /*
  |--------------------------------------------------------------------------
  | Web Routes
  |--------------------------------------------------------------------------
  |
  | Here is where you can register web routes for your application. These
  | routes are loaded by the RouteServiceProvider within a group which
  | contains the &quot;web&quot; middleware group. Now create something great!
  |
  */
  
  $adminPathName = env('ADMIN_PATH');
  
  Route::get($adminPathName . '/test/{locale}', function ($locale) {
      session('lang', 'en');
  
      app()-&gt;setLocale($locale);
      echo App::getLocale();
  });
  
  Route::get('/', function () {
      return view('frontend.home');
  });
  
  $adminPathName = env('ADMIN_PATH');
  $userPath = env('USER_PATH');
  
  Route::get($adminPathName . '/login', 'Admin\LoginController@login');
  Route::post($adminPathName . '/signin', 'Admin\LoginController@signin');
  Route::group(['middleware' =&gt; ['AdminAuth']], function () {
      $adminPathName = env('ADMIN_PATH');
      Route::get($adminPathName . '/dashboard', 'Admin\AdminController@home');
      Route::get($adminPathName . '/languages/manage-languages', 'Admin\LanguageController@index');
      Route::post($adminPathName . '/languages/add-language', 'Admin\LanguageController@addLanguage');
      Route::post($adminPathName . '/languages/add-translate', 'Admin\LanguageController@addTranslate');
      Route::post($adminPathName . '/languages/update-translate', 'Admin\LanguageController@updateTranslate');
      Route::post($adminPathName . '/languages/remove-translate', 'Admin\LanguageController@removeTranslate');
      Route::post($adminPathName . '/languages/remove-language', 'Admin\LanguageController@removeLanguage');
      Route::post($adminPathName . '/languages/sync-language', 'Admin\LanguageController@syncLanguage');
      Route::get($adminPathName . '/languages/translate/{langId}', 'Admin\LanguageController@translateById');
  });
  
  
  // todo this route should be added below .
  Route::get('/login/facebook/callback', 'User\LoginController@facebookCallback');
  
  Route::group(['prefix' =&gt; '/{locale}', 'middleware' =&gt; \App\Http\Middleware\SetLocale::class, 'as' =&gt; 'locale'], function () {
  
      $userPath = env('USER_PATH');
  
      Route::get('/', function () {
          return view('frontend.home');
      });
      Route::get($userPath . '/login', 'User\LoginController@login');
      Route::post($userPath . '/signin', 'User\LoginController@signin');
      Route::get($userPath . '/create-account', 'User\UserController@createAccount');
      Route::post($userPath . '/complete-register', 'User\UserController@completeRegister');
  
      /* Facebook Login &amp; Register  */
  
      Route::get($userPath . '/social/facebook/redirect', 'User\LoginController@facebookRedirect');
      /* ./ Facebook Login &amp; Register  */
  
      /* Google Login &amp; Register  */
      Route::get($userPath . '/social/google/redirect', 'User\LoginController@googleRedirect');
      Route::get($userPath . '/social/google/callback', 'User\LoginController@googleCallback');
      /* ./ Google Login &amp; Register  */
  
      Route::get('/change-language/{lang}', 'User\WebSiteController@changeLanguage');
  
      Route::group(['middleware' =&gt; ['UserAuth']], function () {
          $userPath = env('USER_PATH');
          Route::get($userPath . '/dashboard', 'User\UserController@dashboard');
          Route::get($userPath . '/update-profile', 'User\UserController@userProfile');
          Route::get($userPath . '/website/create-website', 'User\WebSiteController@newWebsite');
          Route::post($userPath . '/card/upload-gallery', 'User\UserController@uploadGallery');
          Route::get($userPath . '/cards/new-card/{card_lang}', 'User\CardController@newCard');
          Route::get($userPath . '/cards/new-card/{card_lang}/{card_key}', 'User\CardController@newCard');
          Route::post($userPath . '/cards/get-card-gallery', 'User\CardController@getGalleryByCardId');
          Route::post($userPath . '/cards/update-card', 'User\CardController@updateCard');
          Route::post($userPath . '/cards/update-card-logo', 'User\CardController@updateCardLogo');
  
          Route::get($userPath . '/logout', function () {
              auth('UserAuth')-&gt;logout();
              return redirect(ulocale_path('/login'));
          });
      });
  
  
  });
  
  
  Route::group(['domain' =&gt; '{account}.localhost'], function () {
      Route::get('/{id}/card', 'User\CardController@shoBusinessCardById');
  });
  </code></pre>
  <p>And <strong>.htaccess</strong> file</p>
  <pre><code>RewriteEngine On
  &lt;IfModule mod_rewrite.c&gt;
   #Session timeout
  
  &lt;IfModule mod_negotiation.c&gt;
      Options -MultiViews
  &lt;/IfModule&gt;
  
     Options +FollowSymlinks
     RewriteEngine On
  
     # Redirect Trailing Slashes...
     RewriteRule ^(.*)/$ /$1 [L,R=301]
  
  RewriteCond %{REQUEST_FILENAME} -d [OR]
  RewriteCond %{REQUEST_FILENAME} -f
  RewriteRule ^ ^$1 [N]
  
  RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
  RewriteRule ^(.*)$ public/$1
  
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^ index.php
  
  
  &lt;/IfModule&gt;
  </code></pre>
  <p>The most time it's error showing in the below route :</p>
  <pre><code> Route::post($userPath . '/cards/get-card-gallery', 'User\CardController@getGalleryByCardId');
  </code></pre>
  <p>Controller Side <code>getGalleryByCardId</code> :</p>
  <pre><code>public function getGalleryByCardId(Request $request)
  {
      $imgs = DB::table('card_docs')
          -&gt;where('user_id', usession('user_id'))
          -&gt;where('card_key', $request-&gt;card_key)-&gt;get();
  
      return $imgs;
  }
  </code></pre>