"Symbolic" link to resolve requests to a folder outside public_html?

2.7k Views Asked by At

I have a lot of image and pdf files in a folder within the public_html directory, and I have a lot of scripts on public_html dynamically processing, creating and editing these files based on user requests.

Now the problem is that I've realized that having these files stored in folders in public_html isn't safe, maybe someone could just inject some script and delete them all! So what I want to do is move them outside public_html. However - since I have so very many scripts dealing with all these files, all the paths will be messed up. I am using scripts that use relative paths, (/home/public_html/designs/product1/...) as well as scripts that use absolute paths (www.mydomain.com/designs/product1/...).

I don't know much about symbolic links to be honest - I've read up some but I found it confusing since I'm not that good with Linux either.

My question is: is there any way that I can put some kind of symbolic link or connection, so that I can move all my product design files outside public_html, and yet don't have to change all my scripts to point to the new path? So maybe, some kind of code that resolves all public_html/designs/ requests from my scripts to the new path? Maybe symbolic links isn't what I need here, but something else?

1

There are 1 best solutions below

1
On

create sysmbolic links is easy in linux

first go to public_html directory :

/home/public_html/

then move designs directory to upper directory [ or every where you want ] mv designs ../

then create sysmbolic link to the real directory

ln -s ../designs designs

every thing will be work