skip to Main Content

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>

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

Any help is highly appreciated

2

Answers


  1. It seems to me like your web server is not pointing to the right folder.

    Laravel expects you to serve the project from the public folder inside the project’s root directory.

    You’re serving it from the main apache/nginx folder. That’s why you need to add the subfolder and public folders in the URL to visit the website.

    Check the Laravel Nginx configuration example to notice the root directory they’re specifying.

    Login or Signup to reply.
  2. Your nginx/apache server is configured wrong

    You must point nginx/apache to the folder

    /var/www/XXX_PROJECT_XXX/

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