Developer9621
Developer9621

Reputation: 111

Block only directories using .htaccess

My directory tree:

/assets
  /css
      style.css
  /js
      script.js

I want to block all direcotries when I open url for example: http://example.com/assets, but I will must open http://example.com/assets/css/style.css

How can I solve this problem using .htaccess on apache server?

Upvotes: 0

Views: 60

Answers (1)

Josh Davenport-Smith
Josh Davenport-Smith

Reputation: 5511

Add this to your .htaccess:

Options -Indexes

This will prevent directory browsing and return a 403 Forbidden status when browsing directly to directories.

Upvotes: 2

Related Questions