Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

342
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!