skip to Main Content

I am struggling to host the multiple laravel project in same server in sub-directory.

I want to run laravel project in example.com/CoreApp and example.com/DataSync

Project Directory:

 - Root directory (example.com): React Js Project
 - CoreApp (example.com/CoreApp) : Laravel Project
 - DataSync (example.com/DataSync) : Laravel Project

Here is the current issue I am facing now.

  • example.com/ => It is working fine.
  • example.com/CoreApp => It is working fine.
  • example.com/DataSync => It is serving me 404 page whereas its other routes are working fine. Like example.com/DataSync/telescope is working fine.

Note: Also, I have added RewriteBase /DataSync and RewriteBase /CoreApp in respective project in .htaccess

Here’s my config:

Server Config:

 - Digital Ocean Server
 - Apache web server
 - Ubuntu 16

Here is what my virtual host look like.

<VirtualHost *:80>

DocumentRoot /var/www/sites/html

Alias /CoreApp /var/www/sites/html/CoreApp

Alias /DataSync /var/www/sites/html/DataSync

<Directory /var/www/sites/html/CoreApp>
   AllowOverride All
   DirectoryIndex index.php
</Directory>

<Directory /var/www/sites/html/DataSync>
   AllowOverride All
   DirectoryIndex index.php
</Directory>


 ServerName www.example.com
 ServerAlias www.example.com
 Redirect permanent / https://example.com/

<Directory "/var/www/sites/html">
    Options Includes FollowSymLinks MultiViews
    AllowOverride All
    Require all granted
 </Directory>
 </VirtualHost>

 <VirtualHost *:443>
  ServerName www.example.com
  ServerAlias www.example.com
  DocumentRoot /var/www/sites/html
  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined

SSLEngine on
SSLCertificateKeyFile /etc/ssl/sites/key/myserver.key
SSLCertificateFile /etc/ssl/sites/certs/example_com.crt
SSLCertificateChainFile /etc/ssl/sites/certs/example_com.ca-bundle


<Directory "/var/www/sites/html">
    Options Includes FollowSymLinks MultiViews
    AllowOverride All
    Require all granted
</Directory>

2

Answers


  1. Change in you virtual host file for Alias as:

    Alias /CoreApp /var/www/sites/html/CoreApp/public
    Alias /DataSync /var/www/sites/html/DataSync/public
    

    you have to provide location of public folder

    Login or Signup to reply.
  2. You should provide URL up to your-directory/public. If still issue. then provide URL up to your-directory/public/index.php.

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