0

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.

Mohammad Salehi
  • 565
  • 1
  • 12
  • 33
  • How do you differentiate between your Laravel and WordPress CMS URLs? "not a secure way because it exposes `.env` file" - it's easy enough to secure any file from direct access. – MrWhite May 12 '22 at 10:53
  • @MrWhite any URL that starts with the directory name (`another-sctipt` in my example) have to handle by WordPress, otherwise it have to handle by Laravel. If I use this way https://stackoverflow.com/a/28735930/6934036 with correct file permissions, it doesn't make a security issue, right? – Mohammad Salehi May 13 '22 at 09:05

1 Answers1

0

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

Mohammad Salehi
  • 565
  • 1
  • 12
  • 33