Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Apache mod_rewrite, restrict non-referrers, allowing www

Posted on 2006-06-16
4
Medium Priority
?
693 Views
Last Modified: 2008-02-26
Hello,

I asked this question yesterday, and got a great solution.
http://www.experts-exchange.com/Web/Web_Servers/Apache/Q_21887572.html

My question is:  In the following .htaccess file (that uses mod_rewrite), how
do I allow referrers with the "www" and without it?


RewriteEngine On
# detect the referrer, match on all other domains
RewriteCond %{HTTP_REFERER} !(http://domain\.com(.*)?$)
# This rule fills all requests with the content of the /denied.html file
RewriteRule ^.*$ /denied.html [L]


Thank you,

Eric
0
Comment
Question by:instantprofits
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
4 Comments
 
LVL 30

Expert Comment

by:callrs
ID: 16926261
Replace line 3 with:
RewriteCond %{HTTP_REFERER} !(.*\.domain\.com(.*)?$)
0
 
LVL 30

Expert Comment

by:callrs
ID: 16926266
No, Nvm. That will catch www.domain.com but not domain.com
brb
0
 
LVL 30

Expert Comment

by:callrs
ID: 16926311
RewriteCond %{HTTP_REFERER} !((\w+):\/\/(([^/:]+\.)|)domain\.com(:\d*)?([^# ]*))

This will allow http://www.domain.com but exclude e.g. http://thedomain.com

0
 
LVL 30

Accepted Solution

by:
callrs earned 2000 total points
ID: 16926328
The above will allow http ftp://  as well as http://, etc.
But to make it ONLY for http:
RewriteCond %{HTTP_REFERER} !((http):\/\/(([^/:]+\.)|)domain\.com(:\d*)?([^# ]*))
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month9 days, 23 hours left to enroll

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question