vendredi 30 juillet 2021

Api routes not found when hosted laravel application on server

I have created my application using laravel and vue.js and hosted my application on server in subfolder inside public_html, Accessing it using url like this:

https://maindomain.in/projectfolder/public/login

but after login if i click on any link it points back to

https://maindomain.in/dashboard

and i get 404 not found in console for the api routes that are accessed for eg. accessing dashboard

https://maindomain.in/api/backend/get-dashboatd-data

My root htaccess file content is :

<IfModule mod_rewrite.c>
RewriteEngine on
</IfModule>

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Force SSL
    RewriteCond %{HTTPS} !=on
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    # Remove public folder form URL
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

and content of .htaccess file inside public folder is

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

Note: Frontend is in Vue.js and backend in laravel.

Any help is highly appreciated



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire