Laravel on a directory, links e.g. login link does not work - laravel

I have uploaded my Laravel app unto a directory under the public folder on my domain,
html_docs/public/store
where 'store' is the folder of my Laravel App. My main domain pointed at 'html_docs/public', please check my laravel app here "https://www.dinhi.org/store/". As you can see, when you click the "sell with us" or "login" on the top header, it returns
Not Found
The requested URL /store/dashboard/login was not found on this server.
I have set up to in my '.env' and in my 'config/app.php' the right url like "https://www.dinhi.org/store/" but still not working, any ideas, help please?
PS: I'm on Laravel 5.3 and I'm using Hesto Multi Auth. In my local, this issue does not exist like everything is good and working.

Laravel is not meant to be installed completely into the document root of your server. Actually, every folder of your laravel application except the public folder should be inaccessible from the web.
Your exposing yourself to a security risk here, since everybody could access every file of your app, including potential .env files with database credentials and the likes.
Cheers
Christoph

Related

Laravel SPA (laravel + vuejs + sanctum) deployed in subdomain returns wrong api

I have this problem since several days.
I'm developing a Vuejs/laravel app, using Sanctum as an authenticator. where laravel mainly have the api gestion role, and I've started to deploying it. On Local, everything looks fine, api and auth are working.
On deploy, since my app is binded to be in a subdomain (laravelapp.maindomain with folder path of domain/laravelapp), when i try to access any page (vue-router) instead of domain/laravelapp/login i get domain/login, even if the page itself is looking fine.
If i try to reload the redirected page (domain/page) i have a 404. Also, since every API is pointing to domain/api/link instead of domain/laravelapp/api/link, everything is broken starting with auth.
I've tried modifying .env file, RouteServiceProvider, .htaccess(but i have no knowledge about that).
I also tried to set the subdomain Document Root to domain/laravelapp (it's the first thing i've done), but not only it dosn't work, if I try to print on screen subdomain's root, it returns domain. It's becoming a real issue right now, thank you for any help.
EDIT: I've discovered something. in the main domain there is a Joomla application. The api route contains the Joomla redirect (like, there is a plugin oh the site that changes language automatically, appending /en /it /de given the chosen language). So, in my case, the api is domain/index.php/en/subdomain. I tried again being more specific with document root, with no results, and playing around with .htaccess, but with no success.

Configuring Laravel project in DirectAdmin server

I'm a newbie to Laravel projects but I need to have one accessible over the internet so I tried using DirectAdmin but whenever I go to my domain I get an index (pictures attached).
I renamed the Laravel 'public' folder to 'public_html', is that correct? Here is my file structure.
Here is what I get when I go to my assigned domain which isn't my website at all.
The webpage should look something like this
I also found a laravel app using Softaculous linked here (https://panel.freehosting.com:2222/CMD_PLUGINS/softaculous/index.raw?act=software&soft=419). Am I required to use this app?
At first, you need to learn about the laravel directory structure. You don't need to change the laravel public folder to public_html. I am not sure how the DirectAdmin server works. but if you see a laravel directory instead of serving an application it's might be a path-related issue in your server. your domain should serve your application public folder.
I just found a tutorial for the DirectAdmin server with laravel. that might help.

Why do i get the "index of" page? (Laravel Nova Web App)

I have uploaded a Laravel Nova project into bluehost and made the changes on the DB name, user, and password, and I assigned the domain to the directory but I'm still getting the (Index of/) page when I open the domain.
That happens because your vhost is pointing to an incorrect directory.
Your apache/any web server should be pointing to /dir/your-project-name/public, however now its currently pointing to /dir/your-project-name (public is missed)
If you have ssh option, edit your vhost to point to /your-project-name/public directory.
If you don't have ssh option (most probably if you're in shared hosting you won't have access to), try renaming the public to public_html and see if that works.
If that still doesn't work, you would need to change the app configuration. Please see this answer

Laravel - how to protect /public/files/uploads/ from web acces by customers

I've got a question.
the admin and employee can upload stuff into /public/files/uploads/
and the customers are only allowed to see a part of the files in uploads.
but when I login as customer and visit: /public/files/uploads/
I can open and view every file.
I would like to know how to protect this from customers, like when they try to open /public/files/uploads/ they redirect back to the home view.
This would need some sort of .htaccess but I can't seem to figure out how to get it working.
Any help would be appreciated.
Thanks in advance.
Try to put an empty index.html file in this folder.
Also, are your normal URLs contain public? If so, you have wrong web server configuration and you should point your web server (Apache, Nginx) to a public directory instead of Laravel project's root folder.

config sentinel to work with "public/index.php" in laravel

I have install Laravel in my VPS, and it's working with the "public/index.php" in the url. I had tried lot more to remove this from url but all are failed, and I have to work with this. Currently I am working on the Sentinel authorization package. It's installed successfully but after login or when i click on the sentinal logo I always get redirected to the "http://myipaddress/tmb/" which is incorrect, so where I can set the home link so that it goes to the "http://myipaddress/tmb/public/index.php/". My laravel version is 5.1.20
The default config for the target URLs is the 'home' route. So you have to setup this route in your routes.php properly.
You can override the default routes in the config/sentinel.php file.
But anyway, it's very dangerous that anyone can access your whole application code directory. You should either forbid access to all resources which are not in /public directory or (much better) configure/ask your VPS to set the document root to your public directory!

Resources