Uploading an Angular 8 project and Laravel on Shared Hosting

纵饮孤独 提交于 2019-12-24 19:34:10

问题


I have created a Single Page Application using Angular 8 which consumes a backend API build using Laravel. Everything is working well on my local machine. Now I want to upload it on a shared hosting via CPanel. I have started by uploading the backend Laravel project inside a subfolder in public_html folder called test-app.

This is because I have configured my domain settings to have a subdomain which points to this subfolder. So basically when a user types test-app.example.com it points to this subfolder where I want the SPA to sit on, if the user types example.com it points to my main website.

Next I have run ng-build on my Angular project locally and the contents have been compiled into a dist folder. I have uploaded the dist folder onto the server but am not sure where to place it in my Laravel project so that when the user types test-app.exmaple.com the 1st page on the SPA opens. I want it to consume the API endpoints of the Laravel project it is sitting on.

My .htaccess file

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^(.*) index.html [NC,L]
</IfModule>

来源:https://stackoverflow.com/questions/56912868/uploading-an-angular-8-project-and-laravel-on-shared-hosting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!