.htaccess querystring

Discussion in 'PHP' started by MyVodaFone, Jun 7, 2010.

  1. #1
    I having some problems with my htaccess code below, it just doesn't work.

    
    Options +FollowSymLinks
    
    RewriteEngine on
    
    RewriteBase /
    
    RewriteCond %{QUERY_STRING} dvd_search_type=(.*)&dvd_max_results=(.*)&dvd_search=(.*)&Go.x=(.*)&Go.y=(.*)
    
    RewriteRule .* search%1-%2-%3-%4-%5\.htm [R,L]
    
    RewriteRule search(.*)-(.*)-(.*)-(.*)-(.*)\.htm$ index.php?dvd_search_type=$1&dvd_max_results=$2&dvd_search=$3&Go.x=$4&Go.y=$5
    
    PHP:
    The above out-puts searchtitle-50-I+Love+You+Phillip-18-10.htm?dvd_search_type=title&dvd_max_results=50&dvd_search=I+Love+You+Phillip&Go.x=18&Go.y=10

    But as you can see it also contains ?dvd_search_type=title&dvd_max_results=50&dvd_search=I+Love+You+Phillip&Go.x=18&Go.y=10

    Can someone point me in the right direction ?
     
    Last edited: Jun 7, 2010
    MyVodaFone, Jun 7, 2010 IP
  2. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,277
    Likes Received:
    33
    Best Answers:
    7
    Trophy Points:
    150
    #2
    Have you tried this?

    
    RewriteRule .* search%1-%2-%3-%4-%5\.htm [L]
    
    Code (markup):
     
    stephan2307, Jun 8, 2010 IP
  3. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #3
    I got it with the following

    
    Options +FollowSymLinks
    
    RewriteEngine on
    
    RewriteBase /
    
    RewriteRule ^search([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ index.php?dvd_search_type=$1&dvd_max_results=$2&dvd_search=$3&Go.x=$4&Go.y=$5 [L]
    
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\?dvd_search_type=([^&]+)&dvd_max_results=([^&]+)&dvd_search=([^&]+)&Go.x=([^&]+)&Go.y=([^\ ]+)\ HTTP/
    
    RewriteRule ^index\.php$ http://domain.com/search%1/%2/%3/%4/%5? [R=301,L]
    
    Code (markup):
    But thanks for your time Stephan
     
    MyVodaFone, Jun 8, 2010 IP
  4. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #4

    BTW add NC at the end to make as case insensitive
     
    roopajyothi, Jun 8, 2010 IP
  5. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #5
    What needs to be case insensitive it works fine as is, searches in both upper and lower case or a mix ?
     
    MyVodaFone, Jun 8, 2010 IP
  6. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #6
    Nope!
    Some times some url for Case Sensitive
    Say a Pass FrOOGLes if not equal to froogles
    When sharing a Link suppose some URL Retrive Data based on Case too!
    until you use not such system then there is no Problem
    Ex: Say if your using a filesharing link or some other Case Sensitive plays role there
     
    roopajyothi, Jun 8, 2010 IP