mod rewrite

Discussion in 'Programming' started by Valiant, Oct 5, 2009.

  1. #1
    Any ideas how I can change:

    viewListings.php?language=Spanish

    Into:

    penpals/language/spanish

    Thanks!
     
    Valiant, Oct 5, 2009 IP
  2. caprichoso

    caprichoso Well-Known Member

    Messages:
    433
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    110
    #2
    I guess you need exactly the inverse conversion:

    User enters "penpals/language/spanish" and you get "viewListings.php?language=spanish" internally.

    I didn't check the code, but it shouldn't be far from this:
    
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^penpals/([^/]+)/([^/]+)$ viewListings.php?$1=$2 [L]
    
    Code (markup):
     
    caprichoso, Oct 5, 2009 IP