Table of Contents
- Apache Web Server Rewrites
- Regular Expressions (Regexes)
- Common Mistakes in Rewrite Rules
- Case 1: Redirecting Your Feed to the Pheedo Feed
- Case 2: Redirecting Using a Hidden Source Feed
- Case 3: Supporting Multiple Feeds
- Case 4: Redirects for Wordpress Blog Software
- Validate Your Feed
- Comments
Apache Web Server Rewrite Module and Rules
For theApache Web Server v1.3 or
later, there are two ways to do redirects with the Pheedo system. Both require the mod_rewrite module that you can
read about here:
Apache mod_rewrite - Apache HTTP Server and also
URL Rewriting Guide - Apache HTTP Server.
Apache Web Server Configuration Requirements
Apache rewrites require one of two configuration options to be enabled
in the local directory configuration, or the rewrite may be ignored entirely,
possibly resulting in access being denied to your local data.
One of these options must be enabled by your system administrator. The
latter of the two is generally enabled in most hosted environments.
Options +FollowSymLinks
Options +SymLinksIfOwnerMatch
Regular Expressions (Regexes)
The mod_rewrite module uses regular expressions. We cannot get
into details in this document but would like to point out some that are used
in the rewrite rules below:
- ! — This means the boolean "not", just like in C, C++,
Java, Perl, etc.
- ^ — Represents the starting point of a string.
- $ — Represents the ending point of a string.
- .* — Is a wildcard match that will match zero or more characters
You can read about Regular Expressions in
Regular-Expressions.info
and test them out on
The Regex Coach.
1. Be sure that RewriteCond %{HTTP_USER_AGENT} is followed
by:
!^Pheedo.* where the "!" means "not", the "^" means the start
of the line and the ".*" at the end means match zero or more characters. If
this final wildcard match is left off, the "Pheedo Monitor" user agent will
not match, so be sure that is there.
2. Make sure the names of all your feeds, hidden or public, are correct.
3. Make sure your feeds are valid with the
Feed Validator.
4. If you are using an .htaccess file, make sure it is
world-readable and that the directory it is in has the AllowOverrides
all directive on. It must also be in the same directory as your
feeds.
5. If your feeds are in separate directories, you must put a
world-readable .htaccess file in every directory for each feed in that
dir.
Another option if you are running Apache is to put the list of rules at the
bottom of the httpd.conf Apache config file, usually found in
/etc/httpd/conf but may be elsewhere. Then you will not need to
create and maintain multiple .htaccess files, but will have to use full
pathnames from your Web root (ServerRoot setting in the Apache
config file for each outgoing feed.
Case 1: Redirecting Your Feed to the Pheedo Feed
The first is the most simple, where our system comes to your feed, under
the HTTP_USER_AGENT name of "Pheedo Monitor" and gets
your feed directly, but anyone else (all RSS readers, Web browsers, robots and
crawlers, and any program that calls the URL of your RSS feed) gets the
Pheedo feed with tracing tags and ads inserted instead.
This is the most straight-forward and simple approach.
In your httpd.conf Apache config file or in a
.htaccess file located either in the same directory where
your feeds are located, you put the following entries:
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} !^Pheedo.*
RewriteRule ^feed.xml$ http://feeds.pheedo.com/examplefeed [R,L]
Please note above: do not use feed.xml
specifically, but rather the name of your own RSS feed, that will end in .xml
or .rdf typically. It is the same feed you registered in Your Account. Also do not use examplefeed
but rather the feed name from our system that is also found in Your Account. Both feed.xml and
examplefeed are merely examples that you must change to match whatever
the name of your feed is and the Pheedo outgoing feed.
Case 2: Redirecting Using a Hidden Source Feed
In this case, you will provide two feeds. One is your actual RSS feed, which will be "hidden" and known only to you and the Pheedo system. This is also some times know as the "back door" approach.
For example, you could publish a feed that is not shown or linked to
anywhere on your Web site (thus it is "hidden" from both browsers and
robots/crawlers) that the Pheedo system would monitor.
Let's say it's called http://yourdomain.com/hiddenfeed.rdf
where yourdomain.com is the name of your site's domain, and
hiddenfeed.rdf is your live RSS feed that is not published or linked
to anywhere on your site.
Our system would be set up to pull all RSS items from that feed, since
only we would know about it, and we would republish an outgoing feed of
the form http://feeds.pheedo.com/examplefeed where
examplefeed should be replaced with the name of the actual
outgoing feed found in Your Account.
In this case, the rewrite rules are as follows:
RewriteEngine on
RewriteRule ^yourfeed.rdf$ http://feeds.pheedo.com/examplefeed [R,L]
Please note above: do not use yourfeed.rdf
specifically, but rather the name of your own publically known RSS feed URL,
which ends with .xml or .rdf typically. It is the same feed you registered in Your Account. Also do not use examplefeed
but rather the one also found in Your Account.
In either case, once you reload or restart the Apache
server, you should now have your published feed redirected automatically
to our system, which will insert ads according to how you have it set up.
Case 3: Supporting Multiple Feeds
This is simply an example of supporting multiple feeds without much
description. Please read the section on the Apache Rewrite Module and Rules before attempting
this.
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} !^Pheedo.*
RewriteRule ^mt/archives/autos.xml$ http://feeds.pheedo.com/examplefeed_autos [R,L]
RewriteCond %{HTTP_USER_AGENT} !^Pheedo.*
RewriteRule ^mt/archives/books.xml$ http://feeds.pheedo.com/examplefeed_books [R,L]
RewriteCond %{HTTP_USER_AGENT} !^Pheedo.*
RewriteRule ^mt/archives/cats.xml$ http://feeds.pheedo.com/examplefeed_cats [R,L]
RewriteCond %{HTTP_USER_AGENT} !^Pheedo.*
RewriteRule ^mt/archives/dvds.xml$ http://feeds.pheedo.com/examplefeed_dvds [R,L]
RewriteCond %{HTTP_USER_AGENT} !^Pheedo.*
RewriteRule ^mt/archives/education.xml$ http://feeds.pheedo.com/examplefeed_education [R,L]
RewriteCond %{HTTP_USER_AGENT} !^Pheedo.*
RewriteRule ^mt/archives/fruit.xml$ http://feeds.pheedo.com/examplefeed_fruit [R,L]
Again, please note: each of the examplefeed_* entries must be the Pheedo feed name in Your Account, and every feed ending in .xml
is your original, validated RSS feed.
Case 4: Redirects for Wordpress Blog Software
This has been testing on Wordpress v1.6 and later versions, but should
work on any version where the feed URL ends in "/feed/".
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} !^Pheedo.*
RewriteRule ^/?feed/?$ http://feeds.pheedo.com/examplefeed [R,L]
Please note: examplefeed above should be
replaced with the Pheedo feed name in Your Account.
Validate Your Feed
To best make sure your feed will work with our system, it is often
helpful to test it with
The Feed Validator which tests
RSS 0.9, 1.0, 2.0 and Atom feeds for validity.
Testing that your feeds are valid before using our system will often
help avoid problems by assuring your original feed is valid to one of
the standards above.