WebFaction
Community site: login faq

It is posible to allow only my domains be served with htaccess? Thanks.

asked 26 Dec '15, 21:55

jorrete
114
accept rate: 0%

Sorry, I'm not sure I understand your question. Can you please provide an example or more detail to what you mean?

(26 Dec '15, 22:57) NickR ♦♦

I have static app serving media from a django appp. I would to allow only be served when required from my django app domain and prevent somebody to hotlink my images.

(27 Dec '15, 00:28) jorrete

Okay, if this is a static app being managed by Django, you should be able to use mod_rewrite. There are quite a few examples online, search for "prevent image hotlinking apache or htaccess". Either add it to the site's httpd.conf or place an .htaccess file in the media dir (given it's not static-only). That should work.

(27 Dec '15, 00:43) NickR ♦♦

Perfect! Thanks for point me to the answer.

(27 Dec '15, 01:06) jorrete

This what I am using.

htaccess

RewriteEngine on
# uncomment this rule if you want to allow blank referers
#RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^(my domain) [NC]
RewriteRule ^ - [R=403,NC,L]
# use this rule if you want to redirect instead of forbid
# RewriteRule \.(jpg|jpeg|png|gif)$ http://hpmouse.googlepages.com/hotlink.gif [NC,R,L]
permanent link

answered 27 Dec '15, 01:11

jorrete
114
accept rate: 0%

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: 26 Dec '15, 21:55

question was seen: 1,427 times

last updated: 27 Dec '15, 01:11

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 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