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

What’s the Best Data Storage System for a Photographer?

I'm a photographer with a lot of RAW and edited images that I need to back up. I've been using a few HDDs and...

How to Fix No Sound on Incoming Calls on My iPhone?

I'm experiencing an issue where I'm not getting any sound for incoming calls on my iPhone. I've tried adjusting the volume, turning my phone...

How to Implement a Generic Builder Pattern in Python with Type Hinting?

Hey everyone! I've been experimenting with a builder pattern in Python, focusing on achieving proper type hinting. I'm trying to create a pipeline that...

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

Erase Gemini Nano Banana Watermark

Below is a simple content eraser tool. It works very similar to the content aware fill tool that is used in Photoshop. You can...

Keep Your Screen Awake Tool

This simple online stay awake tool prevents your computer screen from going to sleep while you have this page open. It runs entirely in your...

Neural Network Simulation Tool

The Neural Network Visual Builder is an interactive, client-side tool designed to demystify deep learning. It allows users to drag-and-drop neural network layers to...

Ray Trace Simulator – Interactive Optical Ray Tracing Tool

This ray trace simulator lets you visualise how light rays move through an optical system in real time. You can trace beams as they...

Interactive CPU Architecture Simulator

This is an Interactive CPU Architecture Simulator that provides a hands-on, visual learning experience for understanding how a processor executes code. It models a...

AI Image Upscaler

Our AI Image Upscaler allows you to upload any image and instantly increase its resolution using advanced upscaling models. Choose between 2x, 3x or...

Latest Posts

Latest Questions