
11-24-11, 09:49
|
|
BOD Member
|
|
Join Date: Jun 2011
Posts: 96
|
|
Tip for Apache - Block viewing a page or a stream to an IP via RewriteRules
Here is a little trick to block an IP address to access a certain content with rewriting rules Apache. I will take here the example of a flow, I want to block access to an RSS feed for a given IP address
Here are the rules for Htaccess in the related rewrites:
Quote:
RewriteCond % {REMOTE_ADDR} ^192\.0\.10\.79$
RewriteCond % {REQUEST_URI} ^ / feed.php? Type = rss *
RewriteRule .* / Error.html [R, L]
|
Basically, it's:
Quote:
If the IP address 192.0.10.79 is equal to
AND
If the requested page is / feed.php? Type = rss
I then redirects to the page / error.html
|
This trick can be handy if someone uses your feed, for example to create a "blog" without respecting the license of your content.
|