Using RSS Feeds and Mod_rewrite to add Classified Listings on your Website
(Page 1 of 4 )
Today we're going to discuss how to put job listings on your site using RSS feeds. You could easily adapt this script to use any type of RSS feeds, but our target for this article is Craigslist.org.
Craigslist.org is an extremely popular classified ads site. With the RSS feeds that they make available to us, we'll be able to create our own classified section that displays various types of ads from craigslist.org. We're going to use RSS feeds and some mod_rewrite to create our site. Craigslist makes their ads available for cities all over the world, and we are going to make our listings available all over the world too.
Our first step is to create a file called ".htaccess." This file contains our mod_rewrite rules:
RewriteEngine on
RewriteRule ^ads/(.*)/(.*)/ rssads.php?city=$1&cat=$2 [QSA,L]
RewriteRule ^ads/(.*)/ rssads.php?city=$1 [QSA,L]
RewriteRule ^ads/$ rssads.php [QSA,L]
What this means is that, whenever someone goes to your site and types in "yoursite.com/ads/", it will take them to rssads.php.
Next, we want to create a file called "rssads.php." This file will contain everything related to this script.
The first line of rssads.php is the base href. This is where you will put the URL of your site.
<base href="http://mysite.com">
For our mod_rewrite work, this is very important, because it tells the site where it is.
Next: Arrays of cities and categories >>
More Link Trading Articles
More By Roger Stringer