This tutorial will show you how to secure your website by blocking public access to subdirectories on your 000webhost website.
1. Log Into the File Manager
One you enter your login details, go to the folder that you want to protect from the general public. You will need to choose a folder and not public_html. This will break your site and will render your website useless.
2. Create the file
- Once you are in the folder, you will now need to create the file to protect that directory. Click the new page button (shown below).
A popup will display prompting you to name the new page. Name the page ".htaccess", but without the quotes. Then, click the "Create" button to create the page.
3. Add the code
Now it's time to add the code that will protect the directory that you are currently in. First, double-click on the new file to open it. Once you have done this, you will need to add the code below and click "Save and Close"
4. Visit the directory
Since you have now added the code, now you need to visit the directory to check if it's now blocked. If you added the code in a folder in public_html, the directory would be at: https://mysite.000webhostapp.com/directory. If you see a "Forbidden" error, you have successfully blocked access to that site directory.
Now you can repeat steps 2 - 4 if you want to protect any other directories.
That's it! Now all of your important files on your website can't be downloaded by the public. Enjoy your protected site!
If you have any questions, please PM me!