How to fix this Laravel 403 Forbidden Permission to access Error in my case?

SYSTEM INFORMATION
OS type and version: Ubuntu 18.04 LTS
Webmin version: 1.984
Virtualmin version: 6.17-3
Related products version: DigitalOcean Droplet (Ubuntu 18.04 LTS)

Hi.

Unable to connect to my site (https://msg.worklx.com/) Laravel, I get the error:
Forbidden You don’t have permission to access this resource.

Knowing that the .htaccess located in the “public” directory contains this:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

So how to fix it ???
I really need your help.

You probably need to completely clear your cache or try a different browser. I connect to it just fine.

Thank you for your reply. But it is because I had deleted all the files from the site to reinstall that you did not notice the error. Please try again, you will find that it is impossible to access it and that the error Forbidden You don’t have permission to access this resource appears when you connect to the URL in question : https://msg.worklx.com/.

Knowing as I said previously that the “public” directory contains a .htaccess file whose content is as follows:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

How then to correct this error to succeed in making my site work ???

IMPORTANT: I specify that my web application is based on Laravel version 8.42.

So please help me.

Then I would guess that your php settings are incorrect. Go to your virtual server, then to Server Settings / php options and see what the php execution mode is set to.

Be aware that I have other PHP - Laravel sites that are under other subdomains that work well. But, it is only this one that poses the problem of: Forbidden You don’t have permission to access this resource.

What do you think ???

Looks good to me.

Just for a test, have you tried doing away with your htaccess and see if it works without it?

The .htaccess file in question is not in the root directory of the site but rather in a “public” folder. Otherwise, there is no .htaccess file in the base directory of the site.

But if it’s good for you, can I see the screenshot from your side ??? What does it show on your side when you log in to: https://msg.worklx.com/ ???
Isn’t the same error (Forbidden You don’t have permission to access this resource) showing up ???

Here’s the source on your page:

403 Forbidden

Forbidden

You don't have permission to access this resource.

So something is completely blocking access to it. I’ve seen that happen with improperly written htaccess files in the public_html folder many times before.

I took the liberty of adding index.php to the address and get this:

404 Not Found

Not Found

The requested URL was not found on this server.

So you’ve got something wrong for sure. It appears that you have nothing in the public_html folder that can actually be processed, hence the 403 forbidden error. And there is no index.php landing page left either, so there’s the 404 error.

Virtualmin is working fine. Something you’re using in it is not.

I figured it out.

You’re going to need to change your Virtualmin setup a bit. What you’re basically doing is using a public folder inside the public_html folder so there’s literally nothing for a browser to see.

If you add public to the address (Tippin's Messenger Demo) You see this:

So what you’re going to need to do is edit your /etc/apache2/sites-available/your-website.conf file. Go to that file and change the document root from /home/yourwebsite-directory/public_html/ to /home/yourwebsite-directory/public_html/public

Then save that file, restart apache and it should work.

Why is the web app in a sub folder under root named ‘public’ and not simply under public_html - or am I missing something obvious.

Ok. Great Thank You For Your Help.

Hello.

I changed DocumentRoot /home/worklx/domains/msg.worklx.com/public_html to DocumentRoot /home/worklx/domains/msg.worklx.com/public_html/public then restart Apache via: sudo service apache2 restart.

And when I try to connect again to https://msg.worklx.com via my web browser, I still get the same error 403 Forbidden You don’t have permission to access this resource.

So why does https://msg.worklx.com keep returning the same error and therefore not working despite changing the DocumentRoot ???

Because whatever you did didn’t change the path. You’re still going to public_html and not public_html/public.

Try this: Go to the Virtual Server in question. Then click on Services (right below the disable and delete tab) Then click on Configure Website.

Down towards the bottom you should see the path to the directories for the site listed. The first should be the path to your public_html directory. Below that is a cgi bin path, then stats, etc.

They should be blue. Go ahead and click on the path that ends with public_html and add /public to the end of it and then click save.

See if that does it.

Thank you for your. I just did it but I see again that it’s the same:

So what is blocking ???

Laravel needs sofar i know something with only public.
If not then they “solved” or you need a different setup.

You have to config the doc root and so look search on the web and please post solution

Also is it server or subserver that domain or…?

I don’t understand you. So what do you suggest me ???

Can’t suggest only knowing public should be set to a good docroot with laravel but no experience so search the web.

If you have experience with it you write others are working , is that on same box?
Can’t help but if you have solution post it here for others. :wink:

Maybe this helps: ??

Website documents sub-directory

This field allows you to change a virtual server’s sub-directory that contains web content from the default ofpublic_html. This can be useful if you have created content or scripts in a directory underpublic_htmland want to make it visible to users accessing your website’s top-level URL.

Under that server then > server configuration > website options

Where exactly you did set the docroot?

You followed this don’t try it if not! ?
Manual Installation | Virtualmin

Service Configuration

Apache

On most platforms Apache must be built with suexec_docroot set to /home. This requires a recompile of Apache, unless an apache2-suexec-custom. We provide packages for the most popular operating systems in our GPL repositories at Index of /gpl . For other systems, you will need to download a source package from your OS vendor and rebuild it with the necessary change.

On Debian and Ubuntu systems, you can instead use the apache2-suexec-custom package. This option requires no rebuild of Apache. Configuring the custom suexec package is performed in /etc/apache2/suexec/www-data, and is as simple as changing the first line from /var/www to /home.

If installing on Ubuntu, you’ll need to edit /etc/apache2/conf.d/php5.conf, and comment out the two SetHandler lines.

That is wild. It should be working.

That has to be a problem with the Laravel software.

Are you sure you have restarted Apache after doing all of this? If you have, about the only other thing I can think of trying on the Virtualmin side is adding a redirect.

You do that on the same Server Configuration tab, down at the bottom where it says Website Redirects.

What you’ll do is hit the add redirect button. Then in the source url path you’ll put your
https://msg.worklx.com

Then where it says Destination you’ll put the URL at other site and put
https://msg.worklx.com/public

in the blank and hit save.

It’s an awful way to have to do it, but try it out and see if it works.

Of course via the Terminal Root of my Droplet on DigitalOcean, I did: service apache2 restart.

But the result fails every time I save:

Why then again, the redirection is a problem or did I do it wrong again ???

Try getting rid of the https:// on the source url.

Just leave the msg.worklx.com