Laravel install in sub folder showing 404 page

Viewed 965

I moved Laravel file to subfolder and hit url localhost/test/public it's working fine but I want to use url localhost/test. I put .htaccess in test folder but than localhost/test showing 404

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
2 Answers

create a .htaccess file in your root path

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/$1 [L,QSA]
  • Mover index.php and .htacces file from public folder to test or App Root folder.
  • Modify index.php like this

    require __DIR__.'vendor/autoload.php';

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

And if your css and js stops working add {{asset('public')}}/ before your imports, for example

<link href="{{ asset('public') }}/demo/demo.css" rel="stylesheet" />
<script src="{{ asset('public') }}/js/core/jquery.min.js"></script>

then you can access your website at http://localhost/test

Related