Simple mod_rewrite help needed

Discussion in 'Site & Server Administration' started by John Colin, Mar 28, 2010.

  1. #1
    I need a very simple/basic help with htaccess

    I have the following line in my .htaccess:
    RewriteRule ^([0-9]+)\-([a-zA-Z0-9-]*)(.*)$ /category.php?id_category=$1 [QSA,L,E]

    it converts dynamic links from (for example category called: computer accessories):
    mysite.com/category.php?id_category=22
    to
    mysite.com/22-computer-accessories

    I want it to be like:
    mysite.com/computer-accessories/


    help plz
     
    John Colin, Mar 28, 2010 IP
  2. nimonogi

    nimonogi Active Member

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    80
    #2
    
    RewriteRule ^([a-zA-Z0-9-]*)(.*)/$ /category.php?id_category=$1 [QSA,L,E]
    
    Code (markup):
    Not sure if it works. You have to test it.
    You should also change the code in your script that handles seo friendly urls.
     
    nimonogi, Apr 1, 2010 IP