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

Why is my CPU overheating again after replacing the thermal paste?

I've got a three-year-old PC with an AIO cooler, and after applying new thermal paste, it ran fine for about a week. Now it's...

Is it feasible to learn C++ and JavaScript at the same time?

I'm currently learning C++ in college, but I'm really interested in exploring JavaScript as well. I'm not sure if I should fully commit to...

Choosing Between 9700X, 9800X3D, and 9900X3D for My CPU Upgrade

Hey everyone! I'm looking to upgrade my CPU from an i7 4790k since it's bottlenecking my FPS even with my 7900XTX. I'm deciding between...

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

Online Hash Generator – String to Hash Converter

Need to quickly generate a hash from a string? Whether you're verifying file integrity, securing data, or just experimenting with cryptographic tools, this simple...

Convert CSV To HTML Table

Need to quickly turn CSV data into an HTML table? Whether you're copying data from Excel, Google Sheets, or another spreadsheet, this tool makes...

Student Group Randomizer

Creating fair and balanced groups in the classroom can be time-consuming — especially when you're trying to avoid repetition, manage different skill levels, or...

Random Group Generator

Need to split a list of people, items, or ideas into random groups? Our free Random Group Generator makes it quick and easy. Whether...

Flip Text Upside Down – Free Online Tool

Ever wanted to flip your text upside down just for fun or to grab someone’s attention in a creative way? This free online Upside...

Raffle Ticket Generator

If you're running a fundraiser, charity draw, or local event and need raffle tickets fast, this free online tool lets you generate and print...

Latest Posts

Latest Questions