Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

iam_imam's avatar

Route redirect error after login

I've uploaded my laravel project to cpanel and the login page has appeared. but when i press login button my url changes to like this

https://mywebsite.com/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/public/

Idk why, but here is my .htaccess file

<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>

and my this is login method in user controller

public function loginAdminProccess(Request $request){
        if(Auth::attempt(['email' => $request->email, 'password' => $request->pass])){
            $request->session()->regenerate();
            return redirect()->intended('/dashboard');
        }else{
            return redirect()->back()->withErrors(['wrong_credential' => true]);
        }
    }

I've separate my public folder and laravel folder like this : https://github.com/IMAMSODIK/logo/blob/main/Screenshot_1.png

index.html and .htaccess file is in public folder

0 likes
5 replies
LaryAI's avatar
Level 58

The issue seems to be with the base URL of the application. The base URL is being repeated multiple times in the URL after login.

To fix this, update the APP_URL in the .env file to the correct URL of the application.

For example, if the correct URL is https://mywebsite.com, update the .env file as follows:

APP_URL=https://mywebsite.com

Then, clear the cache using the following command:

php artisan config:cache

This should fix the issue with the repeated base URL in the login redirect.

Snapey's avatar

Your hosting is off

you should never put your code in public_html folder

public should be the document root for your webserver

only one project per cpanel install

1 like
iam_imam's avatar

@Snapey Previously the main website was running, I want to add a feature for registration. what do I have to do?

iam_imam's avatar

@Snapey or should i change url in form action?

<form method="post" action="/admin">

Please or to participate in this conversation.