How upload a laravel project on a web hosting? - laravel

I'm new in Laravel. I want to create a laravel project but I don't know how to upload the project in my web hosting, Do I need a VPS? or with my web hosting can shared on internet?
VPS is more expensive than Web hosting, and I just have web hosting and obviously I want to upload it there.

It's pretty easy.
You basically need to split your project files into two different folders before uploading.
Steps to take:
All laravel project files inside your public folder should be moved to your public_html folder on your server.
On your server, create a new folder e.g my_app on the same directory level as public_html and move the rest of your laravel project to that.
Go to your public_html/index.php and edit the require and require_once lines to match your directory structure.
In your case, that would be:
From __DIR__.'/../bootstrap/autoload.php'; to __DIR__.'/../my_app/bootstrap/autoload.php';

The easiest way is to keep the structure as it is and upload a .htaccess file at the root.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
on my case for laravel 6 its working parfectly!

Related

deploy Laravel project on subfolder in subdirectory

i need to upload laravel project on sub folder in subdomain because there will be wordpress website,
while i am searching i found that i can use .htaccess, is there another way ? because i am new to laravel and no experience in [tag:.htaccess ]
--- subdmoain.com
--- public_html
--- subfolder
---laravel project
i tried using changing App_Url
Just upload your Laravel files to /public_html/subdomain/
Then create a new file called .htaccess (yes, in the same subdomain folder) and then insert this code so it would start loading index.php from /public_html/subdomain/public/ folder which exists in Laravel App:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
Save it. When you visit your subdomain URL now, the app should work.
If it throws any errors, then most likely your index.php paths aren't correct or you do not have vendor/ folder.
.htaccess is of course the best way. But if you don't know how to do that, I think you can create a subdomain from your hosting provider (like hostinger, etc), and after that, you can upload it to that folder (the one with the subdomain). Ask the hosting provider contact person, they will gladly help you to set up the subdomain

How can i browse laravel application on wordpress website?

I have a website which is build in wordpress and another application which is build on laravel. I want to browse the laravel application from wordpress folder structure.
How can i make it possible ?
http://www.example.com -> primary website
http://www.example.com/app -> laravel application
Thanks in advance.
Do the following:
create app folder on primary website folder
upload and config laravel project on app folder
create the .htaccess file so that it contains the following code
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

Remove /Public from url in Laravel

Good Day!
Hello,
Currently I was working on laravel and im new on it. I keep looking a solutions on my problem and i couldn’t find a solution on this. My laravel work is accessible already without /public in the url I fix this thru .htaccess, but it can be access also with /public in the url. Please see links below for your reference.
https://utok.ph/
https://utok.ph/public
my htaccess file
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
.htaccess files wont work on this, what i did is i update the root directory in my server side.
instead the root will be at public_html I change it to public_html/public

.htaccess redirects in Laravel and on Forge

When migrating an old project to a new, Laravel based project, we would need to redirect (301 Header) old routes to new routes, e.g.
/index.php?page=shop ==> /shop
/index.php?category=abc&product_id=123 ==> /abc/item-123
For this, we've prepared a proper .htaccess file that works perfectly on the old project. However when we deploy the new project and change the domain DNS, the htaccess also needs to be in the new folder.
In Laravel, we do have /public/.htaccess, however, adding our .htaccess pieces won't work together with Laravel Forge. It is a simple .htaccess file that looks like:
<IfModule mod_rewrite.c>
# Enable Rewrite Engine
RewriteEngine On
RewriteBase /
# index.php?page=user&sub_page=settings
RewriteCond %{QUERY_STRING} ^page=user&sub_page=settings$
RewriteRule ^index\.php$ /users/notifications/permissions/edit [R=301,NC,L,QSD]
(... and so on)
</IfModule>
So now we are wondering: how can we make it work, that it will forward old routes to the new routes in the same project based on Laravel?
Laravel Forge uses an nginx.conf file (which you can configure in forge) instead of the .htaccess file.
You can use the nginx reference to re-create your settings: https://nginx.org/en/docs/. You should look at the sections: location and redirect.
Hope This Helps!

Migrating a CodeIgniter site to a different domain and moving the whole thing down one level in directory

I am working on a site, which is built with CodeIgniter.
I have never used the framework before...I've learnt a little bit in the last couple days but really cannot solve my problem.
I have downloaded the site and I want to upload it to my own domain so not to make changes to the live site before testing.
the original site is example.com.
I want to upload it to mysites.com/examplesite (this will be the base - I use this domain for all my clients' test sites).
I have moved all the files and the database is in place.
I have found the database configuration file and have successfully edited it.
I am having trouble getting the site to work, I think it must be because of the site now being down a directory level.
I have edited $config['base_url'] so that it is correct...I am pretty sure it is correct because I can now reach the homepage where I couldn't before editing that variable. But, i can only reach the homepage - when I click on a link to another page, I get 500 error Internal server error.
Does anyone have a quick fix for me?
Thanks!
Keep this code on your project's root .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /examplesite/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

Resources