I'm new to Laravel framework so this question might be a little stupid but here's the problem:
I have a small project on my local machine and now I need to deploy my project to a live environment ( shared hosting ).
The problem is, my project needs to be stored in a sub-directory ( sub-folder ) of the main domain ( eg. my domain will be main.com , and the project will be at main.com/my-project ). I've created a sub folder inside the public_html of the main domain, then I uploaded my project to that sub-directory. At first, when I went to the url main.com/my-project , I see a directory tree ( like localhost ), then I needed to click to public folder to go to my app. So I looked for the solutions on the internet and I tried the .htaccess way, here's my .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/project/public/
RewriteRule ^(.*)$ /project/public/$1 [L,QSA]
</IfModule>
But when I reload the url main.com/my-project , I kept receiving the message URL request not found.
I've been struggling with this issue for a while and still haven't figured it out. Any idea how I can solve this problem? Please help me out, thanks.
Thank you guys for helping, well actually I figured it out somehow. Here's my solutions for anybody who might run into the same problem like I did:
Inside /public_html, I created a folder and named it my-project. Inside my-project folder, I placed all files & assets folders ( css, js ) and .htaccess file here.
Then I went back to the parent level ( same level as /public_html ), I created a folder and name it app-core. I placed all the other Laravel's folders & files here.
The structure is gonna be like this:
public_html
=app-core
--- All others files & folders except **public**
=my-project
--- index.php
--- css
--- js
--- .htaccess
Finally, I went back to edit the index.php like this:
require __DIR__ . '/../app-core/vendor/autoload.php';
$app = require_once __DIR__ . '/../app-core/bootstrap/app.php';
And saved it, then everything was ready to go!
I'm new to Laravel framework so this question might be a little stupid but here's the problem:
I have a small project on my local machine and now I need to deploy my project to a live environment ( shared hosting ).
The problem is, my project needs to be stored in a sub-directory ( sub-folder ) of the main domain ( eg. my domain will be main.com , and the project will be at main.com/my-project ). I've created a sub folder inside the public_html of the main domain, then I uploaded my project to that sub-directory. At first, when I went to the url main.com/my-project , I see a directory tree ( like localhost ), then I needed to click to public folder to go to my app. So I looked for the solutions on the internet and I tried the .htaccess way, here's my .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/project/public/
RewriteRule ^(.*)$ /project/public/$1 [L,QSA]
</IfModule>
But when I reload the url main.com/my-project , I kept receiving the message URL request not found.
I've been struggling with this issue for a while and still haven't figured it out. Any idea how I can solve this problem? Please help me out, thanks.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.