How To Protect a Server Directory From Access Via Browser or URL

There are several ways to protect a directory from URL access but most of these will also block your website from being able to access them. Heres what you do to protect a directory from being accessed by a URL but still let your website access the contents of the directory.

Open the directory you want to protect and create a new file called “.htaccess”. Open the file and add the following line of code.

Options -Indexes

Save the file and try access the directory. You should get a forbidden error e.g. “You don’t have permission to access /images/ on this server.”. If you check your website the images should still be showing up.

You will need to add a .htaccess file to every directory that you want to protect.

Related Articles

Related Questions

Is it safe to use open Wi-Fi at a hotel without a VPN?

Hey everyone! I'm currently at a hotel that offers open Wi-Fi, and I'm using it for social media and checking my emails. A friend...

Can’t Log Into Windows Without Internet – Need Help!

I just built a new PC but I can't log into Windows since I need to change my PIN, which requires an internet connection....

Is It Realistic to Learn Java and JavaScript at the Same Time?

I've always wanted to master Java because it's widely used in established companies. However, I keep seeing a lot of codes and projects involving...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Latest Tools

OpenAI Token Calculator

This tool is a simple OpenAI token calculator, web-based utility designed to help you quickly estimate the number of tokens in your text when...

List Sorting Tool

Welcome to our innovative list ordering and management tool. This next-level platform enables you to sort a list of items in ascending or descending...

Sudoku Solver

Welcome to our free online Sudoku solving tool, an interactive platform for puzzle enthusiasts seeking a break from a Sudoku conundrum. This advanced platform...

Apply Image Filters To Image

Digital imagery in the modern world is all about reinforcing emotions and stories behind each photo we take. To amplify this storytelling, we are...

Add Watermark To Image

As the world is increasingly consumed by digital media, protecting your original images is paramount. We are thrilled to introduce you to our innovative...

CSV To Xml Converter

Welcome to our CSV to XML converter tool, a convenient and user-friendly solution for all your data conversion needs. This versatile tool on our...

Latest Posts

Latest Questions