.htaccess Mod Rewrite

Discussion in 'Search Engine Optimization' started by vinpkl, Dec 12, 2008.

  1. #1
    hi all

    i have my url as
    
    http://localhost/vineet/products.php?dealer_id=12&category_id=2 
    
    Code (markup):
    i want to have it like this
    
    http://localhost/vineet/products/dealer_id/12/category_id/2 
    
    Code (markup):
    i m using the folowing lines in htaccess file
    
    Options +FollowSymlinks
    RewriteEngine On
    RewriteRule ^/?([a-zA-Z_]+)/([a-zA-Z_]+)$ products.php?dealer_id=$1&category_id=$2 [L]
    
    Code (markup):
    but when i type in my browser
    
    http://localhost/vineet/products/dealer_id/12/category_id/2 
    
    Code (markup):
    i get 404 error. object not found

    vineet
     
    vinpkl, Dec 12, 2008 IP
  2. phinelinda

    phinelinda Well-Known Member

    Messages:
    603
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    108
    #2
    I don't think you can have the URL in the above mentioned layout. But yes, I just THINK you cannot. Who knows ? ;)
     
    phinelinda, Dec 12, 2008 IP
  3. jitendraag

    jitendraag Notable Member

    Messages:
    3,982
    Likes Received:
    324
    Best Answers:
    1
    Trophy Points:
    270
    #3
    You may want to change it to following:

    
    /vineet/products.php?dealer_id=$1&category_id=$2 [L]
    
    Code (markup):
    Check your error_log to see what is the rewritten URL and you will be able to fix it quickly.
     
    jitendraag, Dec 12, 2008 IP
  4. gikone

    gikone Member

    Messages:
    72
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    45
    #4
    RewriteEngine On
    RewriteRule ^vineet/dealer_id/([^/]*)/category_id/([^/]*)$ /vineet/products.php?dealer_id=$1&category_id=$2 [L]

    It should work :)
     
    gikone, Dec 13, 2008 IP
  5. sweetfunny

    sweetfunny Banned

    Messages:
    5,743
    Likes Received:
    467
    Best Answers:
    0
    Trophy Points:
    0
    #5
    If you are actually doing this on localhost, make sure you have mod_rewrite enabled in your httpd.conf
     
    sweetfunny, Dec 13, 2008 IP
  6. vinpkl

    vinpkl Active Member

    Messages:
    899
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    58
    #6
    hi gikone

    i tried your code
    
    RewriteEngine On
    RewriteRule ^vineet/dealer_id/([^/]*)/category_id/([^/]*)$ /vineet/products.php?dealer_id=$1&category_id=$2 [L]
    
    Code (markup):
    and typed in my browser
    
    http://localhost/vineet/products/dealer_id/12/category_id/2
    
    Code (markup):
    i m putting htaccess file in vineet folder.

    and received error 404 object not found.

    i have mod_rewrite enabled in your httpd.conf

    vineet
     
    vinpkl, Dec 13, 2008 IP