Forum Moderators: phranque

Message Too Old, No Replies

problems with special characters in rewrite

I've a long url with special characters, and can't get a rewrite rule worki

         

pastorhusk

10:47 am on Sep 30, 2009 (gmt 0)

10+ Year Member



Hi,
I have a long url with various parameters used by a mediaplayer (flowplayer), that I want to simplify for visitors. My problem is that there are various characters in the config url that seem to cause problems. The rewrite brings the visitor to the media player, but the configuration parameters aren't loaded.

Here's the rewrite rule:
RewriteRule ^(.*)/(.*)/flowplayer\.swf$ /flowplayer-3.1.2.swf?config={"clip":{"url":"/video/$2.flv","autoPlay":false,"autoBuffering":true},"plugin
s":{"controls":{"url":"/flowplayer.controls-3.1.2.swf","time":true,"volume":false,"fullscreen":false}}}

I'm guessing that the characters '{','}',',','"', and ':' are part of the problem. I've tried escaping them like this \{ etc, but without any luck.

Can anyone advise me on what the problem may be?

Thanks!

jdMorgan

5:13 pm on Sep 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd suggest changing your rule -temporarily- to an external redirect, so that you can examine the rewritten URL-path in your browser address bar, and then in more detail by using a server headers checker. I like the "Live HTTP Headers" add-on for Firefox/Mozilla browsers and consider it to be "basic kit" for Webmasters, but there are others.

Do that first, and then remove "\" escaping on all characters which do not require it. Then consider using both the [NE] and [L] flags on your rule, combined as [NE,L] to prevent hex-encoding of 'special' characters if needed -- see the mod_rewrite documentation.

Also note that "(.*)/(.*)" is a horribly-inefficient sub-pattern, and you might take a lot of load off your server by making it more specific -- for example, by using "([^/]+)/([^/]+)" if your URL-parameters are always demarcated by slashes (and do not contain slashes themselves).

Jim

pastorhusk

7:49 pm on Sep 30, 2009 (gmt 0)

10+ Year Member



Hi Jim,
Thanks for the very useful suggestions.

Using your method of a temporary external redirect I managed to weed out some of the problems (an errant space in one of the parameters, that was working fine in the original url as an %20 was automatically appended, but with the redirect an 0 was creeping in).

So I got it working fine on the external redirect. When I change back, then, to the internal rewrite, though, it's still not working.

Your suggestions though have got me a lot closer, and on the right track - thanks! (I've also taken on-board your point about the inefficiency of the sub-pattern).

jd01

10:16 pm on Sep 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



My first thought when I looked at this earlier was: Your .swf file (or media player) is set to look for the parameters in the URL, not the Query_String... They're two different places. If you are getting the correct parameters in the Query_String, I would suggest checking the flash files (or media player settings) to see where it's 'looking' for the information to be passed. It might need to be adjusted to look for the information in the Query_String rather than the path.

Edited: Can't *bleepin* type sumtimes!