WebFaction
Community site: login faq

I'd like to use a directory for serving media files to everybody, and allow directory index only for a specific IP for inspection purpose.

I've found plenty of solutions on google, but they restrict the serving only to my IP.

thanks

asked 03 Jun '13, 09:36

Infrid
47510
accept rate: 0%


You can use mod_rewrite to check the IP address, and then rewrite whatever URL to a 403 response if the request doesn't come from your IP.

For example, if your IP is 12.34.56.78:

RewriteEngine on
RewriteBase /
RewriteCond %{REMOTE_ADDR} !(12\.34\.56\.78)
RewriteRule ^$ - [F,L]

This will protect only the root level of your static app, but you can add as many rewrite rules as you want, or modify the regex on the RewriteRule directive to match whatever you need.

Hope that helps!

permanent link

answered 03 Jun '13, 18:35

seanf
12.2k42136
accept rate: 37%

edited 04 Jun '13, 11:55

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×75

question asked: 03 Jun '13, 09:36

question was seen: 2,972 times

last updated: 04 Jun '13, 11:55

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2020 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM