Restricts access to Textpattern pages
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.



Rah_ip_range is a Textpattern CMS plugin for restricting visitors’ access to certain parts of site content based on their IP addresses. The plugin introduces a little Textpattern tag that takes an IP address range and an executed action. The tag can either be used to hide parts of a page template or to invoke a customizable error page.

List of features

  • Deny and allow visitors from accessing site content with IP ranges.
  • Comes with a simple tag, <txp:rah_ip_range />. Include the tag anywhere in your page templates and form partials you want restricting to take place.
  • Blocked visitors can be set to see a Textpattern’s native, customizable error page. Error messages and status codes are fully configurable.
  • Alternatively, the plugin can be used to hide certain parts of a page, without invoking an error page.


<txp:rah_ip_range fromip="" toip="" method="deny">
	...contained statements...

The plugin introduces a new Textpattern tag, <txp:rah_ip_range />. The tag can be used to restrict visitor’s access to certain parts of page template content or full pages based on their IP address. The tag takes an IP range, set by fromip and toip attributes. A visitor that is in the specified range will be either denied or allowed access to the content based on method attribute’s setting.

The tag can be used both as a container and as a self-closing single tag. When used as single tag, the tag invokes an error page when the visitor is within denied range. As a container, the tag hides the wrapped content, but doesn’t invoke an error page. A container can also take a else statement, which is served as an alternative content to denied visitors.


Attributes for <txp:rah_ip_range /> are as follows.

Error message shown to blocked visitors. The message can be displayed with the error_message tag.
Example: message="Sorry, we can not do that." Default: "Forbidden."

HTTP error status code returned to blocked visitors. The option is ignored when the tag is used as a container.
Example: status="404" Default: "403"

IP-range’s starting IP (or partial IP). Default is unset.
Example: fromip="" Default: ""

IP-range’s ending IP (or partial IP). Default is unset.
Example: toip="" Default: ""

Sets what to do to the visitor when IP is within the range. Either deny or allow. When set to deny, all visitors within the range are blocked, and others outside the range are allowed to see the content. Value allow is opposite to the deny.
Example: method="deny" Default: "allow"


Using the self-closing single tag

<txp:rah_ip_range fromip="" toip="" method="deny" message="Access denied." />

Visitors within the range of are blocked will see an error page.

Using the tags as a container

<txp:rah_ip_range fromip="" toip="">
	<a href="">Important link</a>.
<txp:else />
	Link is hidden.

Visitors within the range will see an important link, while others won’t. Instead they are treated with “Link is hidden.” message where the link would be.


Version 0.4 – 2012/07/13

  • Added: else (<txp:else />) tag support for container mode.
  • Changed: default HTTP status to 403 Forbidden from 503 Service Unavailable.
  • Changed: default message to Forbidden., 403_forbidden l18n string.
  • Changed: message attribute doesn’t apply when tag is used as a container, instead of else can be used.

Version 0.3 – 2011/06/29

  • Changed: parsing contents of message isn’t needed. Parser’s straight quote feature can be used instead.
  • Changed: pass parameters to txp_die() as strings instead of an array.

Version 0.2 – 2011/06/25

  • Added: container tag mode.

Version 0.1 – 2008/10/31

  • Initial release.