1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Htaccess for dynamic urls

Discussion in 'Apache' started by snaketorque, Jan 9, 2006.

  1. #1
    Hi everyone.

    Sorry about this, but this is driving me crazy, I can't seem to get an htaccess rewrite rule to work.

    I have a category page url page.php?MerchantCategory=Bras&Manufacturer=&OfferDescription=&sizes= and want to change it to page-X-X-X-X.htm but whatever I do it just doesn't seem to work.

    My htaccess is as follows, the other rewrite rules work correctly.

    Options +FollowSymLinks
    RewriteEngine On
    RewriteRule ^detail_([^\.]+)\.htm$ detail.php?recordID=$1
    RewriteRule ^buy_([^\.]+)\.html$ out.php?recordID=$1
    RewriteRule ^([^\.]+)\.html$ designer.php?Manufacturer=$1
    RewriteRule ^index_([0-9]+)_([0-9]+)\.htm$ index.php?pageNum_Recordset1=$1&totalRows_Recordset1=$2
    RewriteRule ^cats-([^.]+)-([^.]+)-([^.]+)-([^.]+).htm$ page.php?MerchantCategory=$1&Manufacturer=$2&OfferDescription=$3&sizes=$4

    I know the above is a bit of a mess, but I just want to get the structure working before I tidy up a bit :)

    Many Thanks

    Rob
     
    snaketorque, Jan 9, 2006 IP
  2. Big 'G'

    Big 'G' Member

    Messages:
    89
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    48
    #2
    Probaly a typo but...
    But you are using
     
    Big 'G', Jan 9, 2006 IP
  3. snaketorque

    snaketorque Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yes, that was just the last in a long long line of edits and stuff to rey and get it working.

    The latest is...

    RewriteRule page-category-(.*)-manufacturer-(.*)-description-(.*)-sizes-(.*).htm$ page.php?merchantcategory=$1&manufacturer=$2&offerdescription=$3&sizes=$4

    The url for the site is http://www.temptation-lingerie.co.uk

    Rob
     
    snaketorque, Jan 9, 2006 IP
  4. Big 'G'

    Big 'G' Member

    Messages:
    89
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    48
    #4
    You not think that you defeating the object a little as you are still creating a very long unfriendly URL. Have you thought about / rather - might make it easier to follow and be more SEO...None of my biz :) anyhow
    Try adding [R] flag to try and debugg which part is going wrong
     
    Big 'G', Jan 9, 2006 IP
  5. snaketorque

    snaketorque Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I will shorten it later, I needed the long bit, as my brain is currently dribbling out of my ear as no matter what I do, it won't play ball. :D :D
     
    snaketorque, Jan 9, 2006 IP
  6. Big 'G'

    Big 'G' Member

    Messages:
    89
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    48
    #6
    Having a play with it as we speak....the code that is:D
     
    Big 'G', Jan 9, 2006 IP
    madkad likes this.
  7. Big 'G'

    Big 'G' Member

    Messages:
    89
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    48
    #7
    
    RewriteRule page-category-(.+)-manufacturer-(.+)-description-(.+)-sizes-(.+).htm$ page.php?merchantcategory=$1&manufacturer=$2&offerdescription=$3&sizes=$4
    
    Code (markup):
    Is working for me so long as their is a var foreach ie.
    <a href='page-category-1-manufacturer-2-description-3-sizes-4.htm'>1234
    Code (markup):
     
    Big 'G', Jan 9, 2006 IP
  8. snaketorque

    snaketorque Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Hmmm, the thought had crossed my mind as I was eating my jelly and ice cream (Sons birthday tea) that I don't have a value for each one.

    So, is there any way round that?

    Rob
     
    snaketorque, Jan 9, 2006 IP
  9. Big 'G'

    Big 'G' Member

    Messages:
    89
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    48
    #9
    this works for me
     
    Big 'G', Jan 9, 2006 IP
  10. snaketorque

    snaketorque Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    For some reason I get no producst but the page displays.

    Original url

    http://www.temptation-lingerie.co.uk/page.php?MerchantCategory=Non-underwired&Manufacturer=&OfferDescription=&sizes=

    After the rewrite

    http://www.temptation-lingerie.co.uk/page-category-Non-underwired-manufacturer--description--sizes-.htm

    Rule

    RewriteRule page-category-(.*)-manufacturer-(.*)-description-(.*)-sizes-(.*).htm$ page.php?merchantcategory=$1&manufacturer=$2&offerdescription=$3&sizes=$4

    I might just compromise and change the lookups. :(
     
    snaketorque, Jan 9, 2006 IP
  11. Big 'G'

    Big 'G' Member

    Messages:
    89
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    48
    #11
    I take it that Non-underired should be one var becuase the rewrite rule will see it as Non being one var ude to the -

    It may be handy to add this to the page to verify the information that should and is being posted
    
    echo "<pre>";
    print_r($_GET);
    echo "</pre>";
    
    Code (markup):
     
    Big 'G', Jan 9, 2006 IP
  12. snaketorque

    snaketorque Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Yep, but I don't think thats the problem as I also tried with a single entry.

    http://www.temptation-lingerie.co.uk/page-category-Bras-manufacturer--description--sizes-.htm

    I was trying to be clever and save myself a bit of time in doing multiple mapge, should have known better. :D

    Thanks for your help, I will change some of the code to strip down the refs. I know the other htaccess rules are working as the index paging works fine.

    http://www.temptation-lingerie.co.uk/index_01_4503.htm

    Rob
     
    snaketorque, Jan 9, 2006 IP