.htaccess help (remove variables)

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

  1. #1
    How would I go about removing the last two variables 4 & 5 from my final url ?

    
    Options +FollowSymLinks
    
    RewriteEngine on
    
    RewriteBase /
    
    RewriteRule ^search([^/]+)-([^/]+)-([^/]+)-([^/]+)-([^/]+)\.htm?$ index.php?dvd_search_type=$1&dvd_max_results=$2&dvd_search=$3&x=$4&y=$5 [L]
    
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\?dvd_search_type=([^&]+)&dvd_max_results=([^&]+)&dvd_search=([^&]+)&x=([^&]+)&y=([^\ ]+)\ HTTP/
    
    RewriteRule ^index\.php$ http://domain.com/search%1-%2-%3-%4-%5\.htm? [R=301,L]
    
    Code (markup):
    ..and if possible I would also like to remove variable 2
     
    MyVodaFone, Jun 11, 2010 IP
  2. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #2
    Dont do that!
    X and Y may be the starting and ending record values! :)
     
    roopajyothi, Jun 11, 2010 IP
  3. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #3
    I'm not talking about the search string. Its the landing url I'm trying to edit.
     
    MyVodaFone, Jun 11, 2010 IP
  4. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #4
    Nope it wont Work!
    Since there will not be any input when URL is Passed from your Rewritten URL
     
    roopajyothi, Jun 11, 2010 IP
  5. gapz101

    gapz101 Well-Known Member

    Messages:
    524
    Likes Received:
    8
    Best Answers:
    2
    Trophy Points:
    150
    #5
    are you referring to this?
    
    Options +FollowSymLinks
    
    RewriteEngine on
    
    RewriteBase /
    
    RewriteRule ^search([^/]+)-([^/]+)\.htm?$ index.php?dvd_search_type=$1&dvd_search=$3 [L]
    
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\?dvd_search_type=([^&]+)&dvd_search=([^&]+) HTTP/
    
    RewriteRule ^index\.php$ http://domain.com/search%1-%2\.htm? [R=301,L]
    
    Code (markup):
     
    gapz101, Jun 11, 2010 IP
  6. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #6
    Yeah but when the url i passed like this search-1-10-spiderman.htm the value for x and y can be determined! :)
     
    roopajyothi, Jun 11, 2010 IP
  7. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #7
    I have the following working, thanks all, for your help.
    
    Options +FollowSymLinks
    
    RewriteEngine on
    
    RewriteBase /
    
    RewriteRule ^search([^/]+)-([^/]+)\.htm?$ index.php?dvd_search_type=$1&dvd_search=$2&x=$3&y=$4 [L]
    
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\?dvd_search_type=([^&]+)&dvd_search=([^&]+)&x=([^&]+)&y=([^&]+)\ HTTP/
    
    RewriteRule ^index\.php$ http://domain.com/search%1-%2\.htm? [R=301,L]
    
    
    
    Code (markup):
     
    Last edited: Jun 12, 2010
    MyVodaFone, Jun 12, 2010 IP
  8. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #8
    Yeah all i can say it will work when some one search your site
    But when he copies which is in the form of domain.com/search-1-10-spiderman.htm and sends then your DB will be in trouble
     
    roopajyothi, Jun 12, 2010 IP
  9. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #9
    Its working fine, see here
     
    MyVodaFone, Jun 12, 2010 IP
  10. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #10
    What does the value of x and y deals with???
     
    roopajyothi, Jun 12, 2010 IP
  11. gapz101

    gapz101 Well-Known Member

    Messages:
    524
    Likes Received:
    8
    Best Answers:
    2
    Trophy Points:
    150
    #11
    for your additional knowledge, x and y vars are from a submit button :D
     
    gapz101, Jun 14, 2010 IP
  12. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #12
    Yeah a type=image button, but on reflection less is good so I removed it to type=submit instead, I could at a latter date assign a style to it, instead.
     
    MyVodaFone, Jun 15, 2010 IP
  13. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #13
    Oops! I know that Dude! :)
    they are basically requested using Request or Post or Get depending on the method used here
    I asked that what does X and Y values assigned to a variable do here
    Whether the starting and ending records or some other like that?? :D
     
    roopajyothi, Jun 15, 2010 IP
  14. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #14
    MyVodaFone, Jun 15, 2010 IP
  15. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #15
    roopajyothi, Jun 15, 2010 IP
  16. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #16
    If you care to read the page (link) I provided it explains what and why x & y are generated, x & y have nothing to do with the script
     
    MyVodaFone, Jun 15, 2010 IP
  17. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #17
    Where it is said???


    Is this

    I see no X & Y other than that!
     
    roopajyothi, Jun 15, 2010 IP
  18. gapz101

    gapz101 Well-Known Member

    Messages:
    524
    Likes Received:
    8
    Best Answers:
    2
    Trophy Points:
    150
    #18
    you know, you're plain minded or no common sense :D
     
    gapz101, Jun 15, 2010 IP
  19. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #19
    Nope!
    I dont nderstand

    If i am wring i ask you friends to correct my mistake!

    Gapz dont misunderstood me!!! Sorry i have did anything wrong :)
     
    roopajyothi, Jun 15, 2010 IP