title: Publishing Laravel 8.0 on Shared Hosting (.htaccess?)
body: <p>I am working on installing a new Laravel 8 project on GoDaddy, using a shared hosting Apache cPanel server.</p>
  <p>This walkthrough was used:
  <a href="https://medium.com/backenders-club/how-to-host-a-laravel-project-on-a-shared-hosting-via-cpanel-d955d32c528e" rel="nofollow noreferrer">https://medium.com/backenders-club/how-to-host-a-laravel-project-on-a-shared-hosting-via-cpanel-d955d32c528e</a></p>
  <p>After moving the project directory to the cPanel root directory, and moving my Laravel /public files to the cPanel /public_html directory, I've got the server spun up and am able to access the index page using my web route.</p>
  <pre><code>Route Used: 
  Route::get('/', 'App\Http\Controllers\Controller@Index');
  
  Page Visited: 
  www.mywebsite.com/
  </code></pre>
  <p>When using an erroneous / unnamed route (I.E. <a href="http://www.mywebsite.com/unnamed_route" rel="nofollow noreferrer">www.mywebsite.com/unnamed_route</a>), I am redirected to Laravel's default 404 page with the pretty URL as expected.</p>
  <p>However, when I add a new route to my web routes file and navigate to what is supposed to be the pretty URL of the route, I am redirected to another 404 page that redirects / displays to the absolute path of my index file including the username of my shared host.</p>
  <pre><code>New Route: 
  Route::get('/test', 'App\Http\Controllers\Controller@test');
  
  Browse to: 
  www.mywebsite.com/test
  
  URL Displayed: 
  www.mywebsite.com/home/myusername/myprojectname/index.php
  </code></pre>
  <p>I am assuming that this is a simple .htaccess issue, however I am not familiar with .htaccess configurations.</p>
  <p>I would also like to note that when I visit <a href="http://www.mywebsite.com/index.php/test" rel="nofollow noreferrer">www.mywebsite.com/index.php/test</a>, I am directed to the correct page by the Laravel route.</p>
  <p>Directory Structure:</p>
  <pre><code>| cPanel root &lt;br/&gt;
  || myproject &lt;br/&gt;
  ||| Laravel project files (.env, artisan, bootstrap/, storage/, routes/, resources/, etc...) &lt;br/&gt;
  || public_html &lt;br/&gt;
  ||| .htaccess &lt;br/&gt; 
  ||| index.php &lt;br/&gt;
  </code></pre>
  <p>Here is my index.php file:</p>
  <pre><code>&lt;?php
  
  use Illuminate\Contracts\Http\Kernel;
  use Illuminate\Http\Request;
  
  define('LARAVEL_START', microtime(true));
  
  /*
  |--------------------------------------------------------------------------
  | Check If The Application Is Under Maintenance
  |--------------------------------------------------------------------------
  |
  | If the application is in maintenance / demo mode via the &quot;down&quot; command
  | we will load this file so that any pre-rendered content can be shown
  | instead of starting the framework, which could cause an exception.
  |
  */
  
  if (file_exists('/home/myusername/myprojectname/storage/framework/maintenance.php')) {
      require '/home/myusername/myprojectname/storage/framework/maintenance.php';
  }
  
  /*
  |--------------------------------------------------------------------------
  | Register The Auto Loader
  |--------------------------------------------------------------------------
  |
  | Composer provides a convenient, automatically generated class loader for
  | this application. We just need to utilize it! We'll simply require it
  | into the script here so we don't need to manually load our classes.
  |
  */
  
  require '/home/myusername/myprojectname/vendor/autoload.php';
  
  /*
  |--------------------------------------------------------------------------
  | Run The Application
  |--------------------------------------------------------------------------
  |
  | Once we have the application, we can handle the incoming request using
  | the application's HTTP kernel. Then, we will send the response back
  | to this client's browser, allowing them to enjoy our application.
  |
  */
  
  $app = require_once '/home/myusername/myprojectname/bootstrap/app.php';
  
  $kernel = $app-&gt;make(Kernel::class);
  </code></pre>
  <p>And my .htaccess file:</p>
  <pre><code>Options +FollowSymLinks
  RewriteEngine On
   
  RewriteCond %{SCRIPT_FILENAME} !-d
  RewriteCond %{SCRIPT_FILENAME} !-f
   
  RewriteRule ^.*$ ./index.php
  
  
  $response = tap($kernel-&gt;handle(
      $request = Request::capture()
  ))-&gt;send();
  
  $kernel-&gt;terminate($request, $response);
  </code></pre>
  <p>Any assistance would be greatly appreciated in helping me solve this issue.</p>