Linux / UNIX Tech Support Forum
This is a discussion on Apache stop image hotlink with .htaccess within the Web servers forums, part of the Mastering Servers category; i need a referer rewrite condition Domain somedomain.com is hosting from a server and other his sub-domains (sub1.somedomain.com etc) is ...
|
|||||||
| Web servers Discussion on Apache, Nginx and Lighttpd HTTP/web server and configuration issues. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
||||
|
i need a referer rewrite condition
Domain somedomain.com is hosting from a server and other his sub-domains (sub1.somedomain.com etc) is hosting from other machines. I need a RewriteCond for referer. just wanted to restrict the request that comes except from internal domains and sub-domains.Mean Request will be denied if some one tried to fetch some stuffs like images from his own server. I have the followings: RewriteCond "%{HTTP_REFERER}" "!^http://somedomain.com/.*$" [NC] RewriteRule "\.(jpg|gif|png|txt)$" [F] what to do if i have the many sub-domains and different (live otherdomain.com) domains, i wanted to allow ? if i am adding this: RewriteCond "%{HTTP_REFERER}" "!^http://st1.somedomain.com/.*$" [NC] RewriteCond "%{HTTP_REFERER}" "!^http://st2.somedomain.com/.*$" [NC] RewriteCond "%{HTTP_REFERER}" "!^http://otherdomain.com/.*$" [NC] #RewriteCond "%{HTTP_REFERER}" "!^http://%{HTTP_HOST}/.*$" [NC] RewriteRule "\.(jpg|gif|png|txt)$" [F] and using link on st1.somedomain.com lynx http://st1.comedomain.com/mani/hh.php then getting this error: message Warning: file(http://somedomain.com/ma.txt) [function.file]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /var/www/html/hh.php on line 3 Warning: implode() [function.implode]: Invalid arguments passed in /var/www/html/hh.php on line 3 hh.php contains: <?php echo $html = implode('', file('http://somedomain.com/ma.txt')); ?> Last edited by kasimani; 28-05-2009 at 05:50 PM. |
| Sponsored Links | ||
|
|
|
||||
|
Quote:
Pl. let me if some other information also needed! |
|
||||
|
I'm sorry but I don't get your question... can you provide more info? Are you trying to restrict url access? If so you can restrict domains to certain ip address using LIMIT feature.
__________________
Vivek Gite Linux Evangelist |
|
||||
|
Thanks for attention !
I need a url condition, that will prevent Hot-Linking of Images and some text file from other websites. I have many domains and sub-domains. eg. domain1.com and it's so many sub-domains domain2.com and so many sub-domain.... etc etc... Now i want to only allow my domains and their sub-domains to access these files (Images and text files.) I did a little practice on this, and at some extent i achieved the goal.. but that is not a correct way to do this.... as i think. RewriteCond %{HTTP_REFERER} !^http://(.+\.)?(domain1|domain2)\.([a-z.]+) [NC] RewriteRule .*\.(jpe?g|gif|png|txt)$ - [F] Is there any way, that Condition will read all the domains and sub-domains dynamically or from text files. Regards Manish Singh |
|
||||
|
Yes, that is correct way to stop image hot linking. See
Apache prevent hot linking or leeching of images using mod_rewrite howto
__________________
Vivek Gite Linux Evangelist |
|
||||
|
my question is, is there any way that Rewrite Condition will read my all domains and sub-domains from a text file or from some other resources, that will fit in condition rather than using OR ( | ) condition in that
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?(domain1|domain2)\.([a-z.]+) [NC] i have so many domain by different names. domain1.com server.com etc... about 40-50 domains and sub-domains |
|
||||
|
No there is no text file or other file to include. You have to write complex task yourself. This is why they hired you to do all config work
__________________
Vivek Gite Linux Evangelist |
![]() |
| Tags |
| apache image hotlink , stop apache hotlink , stop image hotlink |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Apache Redirect / to index.php using mod_rewrite .htaccess | kasimani | Web servers | 3 | 30-01-2010 12:37 AM |
| Grant Start / Stop Apache Server Permission to Normal User | tanweernoor | Web servers | 3 | 01-12-2008 04:13 AM |
| Lighttpd Wildcard based hotlink prevention | Lamba | Web servers | 1 | 19-05-2008 01:23 PM |
| Lighttpd Hotlink Prevention | Lizard King | Web servers | 1 | 02-05-2008 02:44 AM |
| Apache SYN Flood Attacks and how to stop / avoid them | cbzee | Web servers | 1 | 21-12-2006 03:30 AM |