0

Hello Community,
I was wondering if there is a way to restrict sub directories from accessing the parent directory (the main directory where all my website file are stored) and from having any interaction with the previous folders (so once there in the child folder they can't leave it eg. using ../)

Is there a way doing this using PHP or .htaccess?

Please help...

3
Contributors
7
Replies
9
Views
4 Years
Discussion Span
Last Post by pritaeas
9

@joshl_1995

Is there a way doing this using PHP or .htaccess?

It's better to used .htaccess

0

Hmz. Please clarify the logic that you would want to implement. I have a feeling it will only be possible when using sessions or cookies, and both can be disabled.

0

What i want it so a user can't leave the directory i place them.
That also means they can't use ../ to go back a directory.

0

You just repeated what you said the first time. What exactly are you trying to prevent? Access to pages? Images? Provide some more background information (how/where does a user start etc.), so we can determine the best course of action.

0

What i want is for each users to get there own directory for them to store there files and for them to also run there files; but if they wanted to make a (eg. php) file they could use ../ to get out of there directory which means they would go into the directory that contains my website files and if they wanted to they could delete my files. What i want is for them to be restricted from them leaving there directory using there files (a php file using ../).

Now If you still don't under stand what i mean, you never will because i don't know how else i can explain it any better.

0

This makes more sense, thank you. Have a look at the open_basedir directive in the PHP.INI file. It is possible to set this at run-time as of PHP5.3 I think. If your webhost allows PHP.INI overrides, then you could use a PHP.INI file in each folder, restricting access to only that folder.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.