'Use a Laravel Application alongside another scripts (wp/joomla/...) and remove /public

This is my directory structure:

Public_html
  /app
  /bootstrap
  /config
  /database
  /public
  /resources
  /routes
  /vendor
  /storage
  /another-sctipt

I'm trying to use Laravel application alongside /another-sctipt (wordpress in my case) and remove /public from Laravel URLs.

The problem is when I use a simple .htaccess file to remove public, it shows 404 for /another-sctipt directory.

Now the only way I can do is https://stackoverflow.com/a/28735930/6934036. But it's not a secure way because it exposes .env file (mentioned in comments). Is this really unsecure way even if I change my .env file permission to 600?

And is there a better way to achieve this?

notes:
I can't change webserver configs.



Solution 1:[1]

Now I'm using this code

RewriteEngine On
RewriteCond  !^/another-sctipt/.*$
RewriteRule ^another-sctipt/(.*)$ another-sctipt/ [L]

RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/ [L,QSA]

it works

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mohammad Salehi