How can i browse laravel application on wordpress website? - laravel

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>

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

.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!

How upload a laravel project on a web hosting?

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!

Laravel project hosted in Cpanel gives HTTP ERROR 500

I created laravel 5.2 project and it works perfect in localhost..
Now when I uploaded to cpanel and tried to access through internet it gives me these errors.
access url : "http://orderproject.sutchelinks.com/public/"
error :
The orderproject.sutchelinks.com page isn’t working
orderproject.sutchelinks.com is currently unable to handle this request.
HTTP ERROR 500
what could be the reason??
Create a .htaccess, add the following lines and put the file in your root folder. I see that you've got it working but you're not supposed to have the */public at the end.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</ifModule>
Try it, I got my Laravel application working with this.

How to rewrite URL PrestaShop to hide folder?

I would like to hide my folder where PrestaShop is installed.
To access my shop, I must write http://domain.com/prestashop.
But I want access to my shop like this: http://domain.com.
How can I do this?
If you don't have access to your server configuration.
Add this .htaccess to your / directory.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/Prestashop/.*$
RewriteRule ^(.*)$ /Prestashop/$1 [L]
</IfModule>
Don't forget to change your shop_url in SEO / URL.
You must point your domain name to a specific subfolder.
If you point domain.com on prestashop subfolder then you should change it in your back office:
Preferences -> SEO & URLs
After the change you should disable Friendly URL and then enable it again - Enabling Friendly URL generates .htaccess

Resources