How to allow access to sub folders in laravel? - php

I have laravel installed on my server and I want to add a folder called 'projects' in laravel's root folder and access the projects folder from URL.
What should I do to solve this issue? I want to upload some PHP code demos and allow people to view them.
I have tried playing with the .htaccess but nothing seems to work for me.

public_path(); // Path of public/
base_path(); // Path of application root
app_path(); // Path of app/

Related

Laravel delete file in app folder (root)

How to delete files from Laravel app directory (not the public directory but the one in the root)?
I tried :
\Storage::Delete('App\file.php');
\Storage::Delete('\App\file.php');
\File::Delete('App\file.php');
\File::Delete('\App\file.php');
unlink ('\App\file.php');
Nothing works.
UPDATE:
The file is in something like \App\folder\folder\file.db
When not specifying an absolute path then what is used is the current working directory (the value that getcwd() would return). Usually, that's the /public directory and not the actual project root.
You need to specific an absolute path using the Laravel helpers:
\File::delete(app_path('file.php'));
Note: You can't use the \Storage helpers because they are limited to only work within the app storage folder.

Laravel on sub folder

I am trying to install Laravel 5.3 in sub domain /public_html/mysite
but it's not working should I change .htaccess or what ?
Put the content of public (L5) directly on public_html (be aware of don't overwrite the .htaccess file accidentally) Now in then modify your index.php and your bootstrap.php and it will work just fine
I hope #Nino Armani gave you the right answer. Although you can try with visual video tutorial here-
http://www.tisuchi.com/upload-laravel-projecy-cpanel/
Move everything from project/public folder to project/ folder
Update index.php to have bootstrap path like "./bootstrap"
Add base APP_URL in your .env
Update layout folder paths like {{URL::to('/css/app.css')}}

Some of the directories are accessible from public URL. How to avoid this in yii

In my Yii web application some of the directories are accessible from the public URL (main directory or application folder) like js, css, images etc. How to avoid this problem. This is a major security issue, but I don't know how to fix this. Please help me...
Thanks in advance...
If you're using Apache, you can restrict access to directories doing the following:
Create a .htaccess file in your directory so path/to/directory/to/deny/.htaccess
Open .htaccess and add Deny from all
You have to turn of apache directory listing. Use the link below.
How do I disable directory browsing?
Then change all files and folders permissions of a directory to 644 and 755.
Change all files and folders permissions of a directory to 644/755
Let me know if you need help
Here is some instructions given in documentation.
1) It's important that the directory be writable by the webserver user so that Yii can publish the resources there when needed.
2) When a project has multiple versions (production, testing, development, etc.) do not copy the assets/ folders from one area to another; allow Yii to deploy them automatically in each area.
3) Do not manually edit any file under assets/ - if you have a real need to make a change, find the publishing module, edit the source, delete the subfolder under assets/, and let Yii re-publish the updated files.
4) Do not reference names under the assets/ folder directly (say, to get at some other module's assets). If you need to use that
5) Do not add the contents of the assets/ folder to any source-code control system; these files have master source in other places.
6) It is safe to delete everything under assets/. Yii will re-publish the assets if they are not found under assets/.
Hope it will help you :)

Laravel 4.2 remove /public from URL

I've seen many people posting here on how to remove the /public folder from URL.
E.g. http://some-domain.com/LaravelProject/public/index.php
It's simple. Suppose your Laravel project is in LaravelProject directory. Copy the server.php in the same folder as index.php.
After that, copy the .htaccess file from public folder in LaravelProject, i.e. your Laravel root folder. It should work!

Access content outside CakePhp folder

I have a CakePHP project uploaded to the server:
httpdocs/cakephp/app/...
My domain name, for example www.mydomain.com is directed to httpdocs/cakephp
Now.. I need to access an image folder that it's otside the webroot of CakePhp:
httpdocs/resources/images/...
The problem is that I can't see files outside the cakephp folder when I go to www.mydomain.com, If I try with ../../resources/images.... I just get www.mydomain.com/resoures/images with an error.
How can I solve this?
Thank you!
Just symlink the resouces folder in your webroot folder.
Alternatively you can send the files through php. The CakePHP book describes this here for >2.3 and here.
Also it is not a good idea to put the whole cake folder in the root of your domain, you should set your app/webroot has the root of your host.

Categories