Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

340
Vistas
How to set rewrite rule to go to frontend and backend in same server with apache

I have a Vue.js project and Laravel project in apache.

I put Vue.js at C:/Apache24/htdocs/vue_project_name, put Laravel at C:/Apache24/htdocs/laravel_project_name, so I can get the configuration as below:

Virtualhost DocumentRoot: "C:/Apache24/htdocs/".

Frontend URL: "http://domain_name/vue_project_name"

Backend URL: "http://domain_name/laravel_project_name"

Backend API URL: "http://domain_name/laravel_project_name/public/api"

I want to rewrite the URL when I input http://domain_name, browser will direct to http://domain_name/laravel_project_name. And I input http://domain_name/api, browser will direct to http://domain_name/laravel_project_name/public/api.

For example, I have an API, I can call http://domain_name/laravel_project_name/public/api/login to get the resource but I want it simplify to http://domain_name/api/login to get the resource.

How to do that?

It is my httpd-vhosts.conf:

<VirtualHost *:80>
    DocumentRoot "C:\Apache24\htdocs"
    ServerName domain_name
    ErrorLog "C:\Apache24\logs\error.log"
    CustomLog "C:\Apache24\logs\access.log" combined
    <Directory "C:\Apache24\htdocs"> 
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

I know how to do that when I input http://domain_name, apache will direct to http://domain_name/laravel_project_name, it seem like:

<VirtualHost *:80>
    DocumentRoot "C:\Apache24\htdocs\vue_project_name"
    ServerName domain_name
    ErrorLog "C:\Apache24\logs\error.log"
    CustomLog "C:\Apache24\logs\access.log" combined
    <Directory "C:\Apache24\htdocs\vue_project_name"> 
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

But I think it will affect backend path, so I need a better solution.

Thanks.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Laravel has to be pointed to <project_root>/public, that is your problem...

Update the config related to laravel to be DocumentRoot: "C:/Apache24/htdocs/laravel_project_name/public".

I know you are using Apache, but see how the Nginx configuration points to that folder.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda