[Solved] htaccess RewriteRule

Discussion in 'General' started by ltd82, Dec 22, 2010.

  1. ltd82

    ltd82 New Member

    I am trying a redirection which is not working.

    RewriteRule ^iembed\.swf\?key=(.*) http://www.domain.com/nvlab/player/player.swf?config=http://www.domain.com/nvlab/econfig.php?key=$1 [R=301,L]

    Any help will be appreciated.
  2. webizen

    webizen New Member

    Last edited: Dec 22, 2010
  3. ltd82

    ltd82 New Member

    perfect :)

    Thank you.
  4. ltd82

    ltd82 New Member

    webizen, Any idea why would IE not respect the redirect. It's working fine in FF/Chrome. Ie is showing a black box instead of playing video.
  5. webizen

    webizen New Member

    Does this problem apply for any specific IE? Does your target URL work for IE?
  6. ltd82

    ltd82 New Member

    It's happening in IE6,7,8. I just sent you URL link in PM
  7. webizen

    webizen New Member

    If I paste the URL in IE, it gets redirected to the substitution URL correctly and video is playing as well.
  8. NiteWave

    NiteWave Administrator

    how about modify rewrite rule slightly:
    Code:
    RewriteCond %{QUERY_STRING} key=(.*)                                                                                                
    RewriteRule ^iembed\.swf http://www.domain.com/nvlab/player/player.swf?config=http://www.domain.com/nvlab/econfig.php&key=%1 [R=301,L]
    
  9. ltd82

    ltd82 New Member

  10. NiteWave

    NiteWave Administrator

    please try: replace "&key=%1" to "\%3Fkey=%1". i.e.
    Code:
    RewriteCond %{QUERY_STRING} key=(.*)                                                                                 
    RewriteRule ^iembed\.swf http://www.domain.com/nvlab/player/player.swf?config=http://www.domain.com/nvlab/econfig.php\%3Fkey=%1 [R=301,L]
  11. ltd82

    ltd82 New Member

    Nopes this one doesnt work at all in any browser.
  12. webizen

    webizen New Member

    Just put the issue summary here so everyone is clear:

    Server side has following redirect setup
    Code:
    RewriteRule ^iembed\.swf\?key=(.*) http://www.domain.com/nvlab/player/player.swf?config=http://www.domain.com/nvlab/econfig.php?key=$1 [R=301,L]
    
    When request to http://www.domain.com/iembed.swf?key=abcdef, it will be redirected to http://www.domain.com/nvlab/player/...//www.domain.com/nvlab/econfig.php?key=abcdef as defined. This works fine for the direct request in any browser and video is playing.

    However, html code
    Code:
    <embed src="http://www.domain.com/iembed.swf?key=abcdef" ... /> 
    
    does not work in IE (work in FF/Chrome/Safari) since IE does not pass query string on redirect in this situation (redirect a request to a swf to another file, and add new request parameters in the redirect, IE will not pass the new parameters to the final object. It will only pass the original query params). Hence video is not playing.

    Clearly, this is not a LiteSpeed issue but IE.

    To work around this IE issue, you can try:

    1. Remove "config=http://www.domain.com/nvlab/econfig.php?" from the rewrite rule. i.e. stick with original query parameter. Of course, swf code may need to be adjusted.
    Code:
    RewriteRule ^iembed\.swf\?key=(.*) http://www.domain.com/nvlab/player/player.swf?key=$1 [R=301,L]
    
    2. If possible, put the substitution URL directly in the html code
    Code:
    <embed src="http://www.domain.com/nvlab/player/player.swf?config=http://www.domain.com/nvlab/econfig.php?key=abcdef">
    
    Last edited: Dec 23, 2010

Share This Page