1

I want to deploy the Laravel project to my shared hosting.

When I go to my site main domain (example.com) It displays all directory and files but (example.com/public) works fine.

What if I just create an index.php file in the project root directory with following code

<?php
header('Location: ./public');
?>

It just redirects me to example.com/public.

Just tell me if there will be an issue that may occur at any point? I am new to Laravel.

I don't care to remove the public directory. I only care if someone goes to example.com then it just redirects example.com/public to work fine.


Update

Just keep it short and simple answer (Yes/No) then explain it.

Is there will be an issue that occurs with the above steps (actions)? (Yes/No)

Abhishek Kumar
  • 738
  • 1
  • 9
  • 17
  • try to change your Laravel app's base directory. – Salim Ibrohimi Jun 27 '20 at 09:30
  • Does this answer your question? [How to set the base path in Laravel 5](https://stackoverflow.com/questions/31805814/how-to-set-the-base-path-in-laravel-5) – Salim Ibrohimi Jun 27 '20 at 09:31
  • Probably this can help https://stackoverflow.com/questions/35461322/upload-laravel-5-to-server-subfolder/35474800#35474800 – Donkarnash Jun 27 '20 at 17:48
  • Hey guys, thanks for comments and answers but those are not relevant to my question. I have updated (added) two more lines to keep the answer short and simple. Thanks again. I hope you will understand. – Abhishek Kumar Jun 28 '20 at 11:09

2 Answers2

0

did you point your vhost to to the public directory?

For Apache

DocumentRoot [Laravel root direcoty]/public

For Nginx

root [Laravel root direcoty]/public;

Laravel Deploment

wizardofOz
  • 127
  • 11
0

I'd suggest the easy way, by create a symbolic link of public_html and link it to your laravel project's public directory. don't forget to set your project folder permission.

here's the example: https://blog.netgloo.com/2016/01/29/deploy-laravel-application-on-shared-hosting/

jamelwa
  • 31
  • 1
  • 4