Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide parent directory /www

Tags:

html

web

I am uploading my project containing folders with all the scripts, PHP, CSS etc, and the index.html

Let's say the URL looks like this www.mydomain.com/project/web/index.html

Inside the parent folder "project", all my files are visible and easily accessible to download (which they shouldn't) if they simply enter www.mydomain.com/project/

Question: Is there any way to HIDE all the parent folders and documents and only make my /index.html accessible?

My server is not an Apache so I can not setup an .htaccess file and build rules to hide/redirect and return a 404 Error page.

like image 446
Mykita Avatar asked Sep 11 '17 11:09

Mykita


People also ask

What does parent directory mean in HTML?

Refers to the directory above another directory. Every directory, except the root directory, lies beneath another directory. The higher directory is called the parent directory, and the lower directory is called a subdirectory.


3 Answers

You could set up a index.html in your projects folder or any other folder that you don't want them to have access.

Then in those index.html pages you can add redirects to push the user to your true homepage. You would place this code in the head of that index.html

<meta http-equiv="refresh" content="1; url=www.mydomain.com/project/web/">
        <script type="text/javascript">
            window.location.href = "www.mydomain.com/project/web/"
        </script>

I still think the best way is to use a .htaccess. But if you have no other choice this will work for folder based access.

This would not prevent people from accessing the file directly such as www.mydomain.com/project/file.txt

like image 195
Niles Tanner Avatar answered Sep 29 '22 12:09

Niles Tanner


Actually, your server is Apache.

This is from their documentation:

What is the difference between the old and new webservers? The operating system on all new webservers are running Debian 8 Jessie, up from Debian 7 Wheezy.

Apache is upgraded from Apache 2.2 to Apache 2.4. If you are running your own .htaccess-file (especially accesscontrol) on your webhotel, this may need to be upgraded. Check Apache-documentation for more information.

We are now using uWSGI to run PHP, instead of suPHP (mod_suphp).

Link to documentation: FAQ

Link to rewrite_mod for Apache 2.4 Apache 2.4

like image 34
SouXin Avatar answered Sep 29 '22 12:09

SouXin


You can try my idea.

  1. Create an index.html or index.php file inside of a folder you dont want the user to access, for example, the project folder; so when a user attempts to visit www.mydomain.com/project and see the content, the index.html will be showed instead. OR
  2. Create a condition there which redirect the user to index.html using php or JavaScript.
like image 37
Jie Avatar answered Sep 29 '22 10:09

Jie