How to rewrite url with php

Discussion in 'PHP' started by phpPig, Dec 27, 2009.

  1. #1
    I have tried to do a redirect using mod rewrite and redirect file rewriting the headers of the redirect file on click but to no avail. I am getting my butt kicked with this and would like to change the urls if possible of an rss feed to show my site but to redirect to craigslist.

    An example of what I am talking about can be seen here: http://alabamatombigbeefishing.info/boat_classifieds/mobile_al.html
    I would like the url of each link to say something like alabamatombigbeefishing.info/boat_classifieds/go/ then maybe the title of the page. I am sure that I am thinking in a box and cannot get beyond my thoughts.

    Any ideas?

    The code is using magpie RSS to list the feed into the site:

    <?php
    require_once('magpierss/rss_fetch.inc');
    $url = "http://mobile.craigslist.org/boa/index.rss";
    $rss = fetch_rss ( $url );
    echo "<ul>";
    foreach ($rss->items as $item) {
    $href = $item['link'];
    $title = $item['title'];
    $description = $item['description'];
    $description = str_replace("a href","a target='_blank' title='$title' href", $description);
    echo"<li><a href=$href target='_blank' title='$title'><h2>$title</h2></a></li><p>$description</p>";
    }
    echo"</ul>";
    ?>
    Code (markup):
     
    Last edited: Dec 27, 2009
    phpPig, Dec 27, 2009 IP
  2. phpPig

    phpPig Peon

    Messages:
    128
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Nevermind...I rewrote urls using .htaccess....I knew there was something that I just wasn't seeing.
     
    phpPig, Dec 27, 2009 IP
  3. Izonedig

    Izonedig Member

    Messages:
    150
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    28
    #3
    Yes, .htaccess is much BETTER :) :)
     
    Izonedig, Dec 29, 2009 IP