skip to Main Content

I have a Laravel + Filament environment running locally and I had setup some Github actions to deploy on a shared hosting, depending on the pushed branch (branch develop -> develop public_html/develop directory and branch staging -> public_html/staging directory).

I setup the database and .env file.

When I push to develop, the Action clones the repo at develop branch and runs composer install and the migrations, but it is not working:

  • If I go to /develop it raises 403
  • If I go to /develop/public it shows the default laravel page
  • If I go to /develop/public/admin it shows the default Filament login form (and it is correct!), but when I enter the user and password the page does not change (only refreshes)

I do not know how to setup the htaccess files neither where to put the files properly.

Can you help me?

2

Answers


  1. Just try following answer.

    How do you redirect all request to public/ folder in laravel 5

    This is what I did:

    COPY htaccess file from the public folder to the root folder (keep the original file in public only) and add two extra lines to the htaccess file in the root folder.

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

    Root folder htaccess file looks like 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]
    
        # Remove public URL from the path
        RewriteCond %{REQUEST_URI} !^/public/
        RewriteRule ^(.*)$ /public/$1 [L,QSA]
    
        # Send Requests To Front Controller...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php [L]
    </IfModule>
    

    Hope this answer will help!

    Login or Signup to reply.
  2. If you are using GitHub for deploying on cPanel especially when ssh and terminal is enabled then follow this guide:

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search