Help with Htaccess mod rewrite

Discussion in 'Web Design and Development' started by Cabbit, Apr 24, 2009.

  1. Cabbit macrumors 68020

    Cabbit

    Joined:
    Jan 30, 2006
    Location:
    Scotland
    #1
    i am using a mod rewrite rule in my .htaccess document, however when we get into tiers past 1 it fails.
    Say i have domain.com/forum as domain.com?page=forum

    RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?page=$1
    RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?page=$1

    But say i want domain.com/forum/forumdisplay/12 where that is domain.com?page=forum&sub=forumdisplate&topic=12

    how do i go about this?

    my thoughts are on something like this
    RewriteRule ^forum/(.*)-([0-9]+)-([0-9]+)\.html$ index.php?page=$1&sub=$2&topic=$3 [L]


    link
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    Give this a go,
    Code:
    RewriteRule ^([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/([0-9]+)$ index.php?page=$1&sub=$2&topic=$3
     
  3. Cabbit thread starter macrumors 68020

    Cabbit

    Joined:
    Jan 30, 2006
    Location:
    Scotland
    #3
    link

    I get a 404 page not found with that.
     
  4. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #4
    That links points to localhost.

    Can you tell what the result was, the format?

    Also, I notice in your attempt you have a html portion, that doesn't seem to match up with what you described. Did you leave something out of your description of what you need perhaps?
     
  5. Cabbit thread starter macrumors 68020

    Cabbit

    Joined:
    Jan 30, 2006
    Location:
    Scotland
    #5
    new link new link

    sorry bout local host. ok it works as long as i have 3 values
     
  6. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #6
    Correct, that's what I thought you were going for. Are there other cases that need to be handled? If so it would likely require a second rewrite line.
     
  7. Cabbit thread starter macrumors 68020

    Cabbit

    Joined:
    Jan 30, 2006
    Location:
    Scotland

Share This Page