Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SetEnvIfNoCase Referer

Status
Not open for further replies.

jhsands

IS-IT--Management
Aug 25, 2006
5
US
[1] I read [2] Can someone help me clean this up?
[3] I would like to allow one file, jhsands.jpg to be accessed by everyone (any referrer).
[4] Thank you :)

Code:
SetEnvIfNoCase Referer "^[URL unfurl="true"]http://bulletin.myspace.com/"[/URL] locally_linked=1
SetEnvIfNoCase Referer "^[URL unfurl="true"]http://bulletin.myspace.com$"[/URL] locally_linked=1

SetEnvIfNoCase Referer "^[URL unfurl="true"]http://comments.myspace.com/"[/URL] locally_linked=1
SetEnvIfNoCase Referer "^[URL unfurl="true"]http://comments.myspace.com$"[/URL] locally_linked=1

SetEnvIfNoCase Referer "^[URL unfurl="true"]http://profile.myspace.com/"[/URL] locally_linked=1
SetEnvIfNoCase Referer "^[URL unfurl="true"]http://profile.myspace.com$"[/URL] locally_linked=1

SetEnvIfNoCase Referer "^[URL unfurl="true"]http://otherdomain.com/"[/URL] locally_linked=1
SetEnvIfNoCase Referer "^[URL unfurl="true"]http://otherdomain.com$"[/URL] locally_linked=1
SetEnvIfNoCase Referer "^[URL unfurl="true"]http://www.otherdomain.com/"[/URL] locally_linked=1
SetEnvIfNoCase Referer "^[URL unfurl="true"]http://www.otherdomain.com$"[/URL] locally_linked=1

SetEnvIfNoCase Referer "^[URL unfurl="true"]http://domain1.com/"[/URL] locally_linked=1
SetEnvIfNoCase Referer "^[URL unfurl="true"]http://domain1.com$"[/URL] locally_linked=1
SetEnvIfNoCase Referer "^[URL unfurl="true"]http://www.domain1.com/"[/URL] locally_linked=1
SetEnvIfNoCase Referer "^[URL unfurl="true"]http://www.domain1.com$"[/URL] locally_linked=1

SetEnvIfNoCase Referer "^[URL unfurl="true"]https://domain1.com/"[/URL] locally_linked=1
SetEnvIfNoCase Referer "^[URL unfurl="true"]https://domain1.com$"[/URL] locally_linked=1
SetEnvIfNoCase Referer "^[URL unfurl="true"]https://www.domain1.com/"[/URL] locally_linked=1
SetEnvIfNoCase Referer "^[URL unfurl="true"]https://www.domain1.com$"[/URL] locally_linked=1

SetEnvIfNoCase Referer "^$" locally_linked=1
<FilesMatch "\.(gif|png|swf|pdf|doc|zip|rar|jpe?g)$"> 
  Order Allow,Deny
  Allow from env=locally_linked
</FilesMatch>
 
Unless I am grossly misunderstanding you, I'd just use the simple <files> directive. If you are only talking about one particular file that will be access by all, then try this:

Code:
<Files jhsands.jpg>
allow from all
</files>

 
Thank you RhythmAce.

I would also like to clean up the code... get rid of http and https... 2nd level and 3rd level to one... maybe something like...

Code:
SetEnvIfNoCase Referer "^http?://*.domain1.com/" 
SetEnvIfNoCase Referer "^http?://*.otherdomain.com/" 
[code]

???
 
I'm not sure what you want to do here. What do you base your decision on? In other words what is the determining factor in the referer?
 
I want to put all of this

Code:
SetEnvIfNoCase Referer "^[URL unfurl="true"]http://domain1.com/"[/URL] locally_linked=1
SetEnvIfNoCase Referer "^[URL unfurl="true"]http://domain1.com$"[/URL] locally_linked=1
SetEnvIfNoCase Referer "^[URL unfurl="true"]http://www.domain1.com/"[/URL] locally_linked=1
SetEnvIfNoCase Referer "^[URL unfurl="true"]http://www.domain1.com$"[/URL] locally_linked=1

SetEnvIfNoCase Referer "^[URL unfurl="true"]https://domain1.com/"[/URL] locally_linked=1
SetEnvIfNoCase Referer "^[URL unfurl="true"]https://domain1.com$"[/URL] locally_linked=1
SetEnvIfNoCase Referer "^[URL unfurl="true"]https://www.domain1.com/"[/URL] locally_linked=1
SetEnvIfNoCase Referer "^[URL unfurl="true"]https://www.domain1.com$"[/URL] locally_linked=1

All into one line.

The referrer will be whatever link they go on my site... some links secured... some not... some domain1.com,
I'm just not sure how to do the regex and wildcard to put it on one line.
 
Hi

The regular expression theoretically is this. I have no time now to try it in Apache too.
Code:
SetEnvIfNoCase Referer "^https?://([URL unfurl="true"]www\.)?domain1\.com(/|$)"[/URL] locally_linked=1

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top