Mobile app version of vmapp.org
Login or Join
Pierce454

: Using Mod_Rewrite To Block Referrer Based On Domain Extenstion? I've been in web development for several years now (I'm a student web designer), and recently, I've begun to experiment with mod_rewrite

@Pierce454

Posted in: #ModRewrite

I've been in web development for several years now (I'm a student web designer), and recently, I've begun to experiment with mod_rewrite for things like URL shortening.

I was wondering, is it possible to block a referrer by domain extension, instead of just by full site, etc.?

So, instead of

RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} examplesite.com [NC]
RewriteRule .* - [F]


could you do

RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} .com [NC]
RewriteRule .* - [F]


without the full domain name?

Thanks. I'm fairly knowledgeable about other web dev / hosting topics, but mod_rewrite is new to me and Google wasn't helping.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Pierce454

1 Comments

Sorted by latest first Latest Oldest Best

 

@Moriarity557

Sure. The right hand expression of the RewriteCond is simply a regular expression. The correct regular expression for matching anything ending in ".com" is:

.com$


The $ means "end of string".

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme