Help with htaccess

Discussion in 'Programming' started by sunnymonkey, Jul 21, 2007.

  1. #1
    Ok, for the most part I have got this sorted. But I need a little help if that is ok?

    Here is my htaccess:

    ErrorDocument 404 /404.html
    RewriteEngine On
    RewriteRule ^rss.xml$ index.php?page=rss
    RewriteRule ^([a-z0-9+])/([a-z0-9+])_([a-z0-9+])/$ index.php?page=details&entryid=15
    RewriteRule ^([A-Za-z0-9]+)/$ index.php?page=listcategory&category=$1
    
    Code (markup):
    Now line 1 works
    line 2 works
    line 3 works
    line 4 DOES NOT WORK
    line 5 works

    Can someone explain what I am doing wrong with line 4?
    Line 4 is
    RewriteRule ^([a-z0-9+])/([a-z0-9+])_([a-z0-9+])/$ index.php?page=details&entryid=15

    And should be working from a url of
    /ebooks/10_product_name_in_url_here/

    If anyone can help I would be most thankful.

    Kind Regards,
    David
     
    sunnymonkey, Jul 21, 2007 IP
  2. DavidAusman

    DavidAusman Peon

    Messages:
    399
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    RewriteRule ^([a-z0-9+])/([a-z0-9+])_([a-z0-9+])/$ index.php?page=details&entryid=15

    Im just curious, why did you put ID 15 after entryID variable?
    It seems that you have only pass 2 variables, so you can use this
    
    //Using 3 (..) means you are passing 3 variables, but in your case you only
    //have 2.
    RewriteRule ^([a-zA-Z0-9]+)/(.*?)\/$ index.php?page=details&entryid=15
    PHP:
    Or just in case the variable you are passing is after the "_" underscore and doesn't need the rest, then you can use either one. Depends which one suit your situation. But Im still confused, why did you use static variable value instead of dynamic, then what is the use of rewriting the URL?
     
    //try this
    RewriteRule ^([a-zA-Z0-9]+)/[^>]+_(.*)\/$ index.php?page=$1&entryid=$2 [L]
    
    //or this
    RewriteRule ^[^>]+/[^>]+_(.*)\/$ index.php?page=$details&entryid=$1 [L]
    
    PHP:
     
    DavidAusman, Jul 21, 2007 IP