Forum Moderators: phranque
The URL is
domain.com/section/MusicTracks/search/word/word/word
but the browser shows...
domain.com/section/MusicTracks/search/word%2Fword%2Fword
RewriteRule ^section/MusicTracks/search/(.*)$ cgi-local/amazon_products_feed.cgi?Operation=ItemSearch&SearchIndex=MusicTracks&Keywords=$1 [L]
RewriteRule ^section/MusicTracks/search/(.*)/(.*)$ cgi-bin/file.cgi?Operation=ItemSearch&SearchIndex=MusicTracks&Keywords=$1 [L]
RewriteRule ^section/MusicTracks/search/(.*)/(.*)/(.*)$ cgi-bin/file.cgi?Operation=ItemSearch&SearchIndex=MusicTracks&Keywords=$1 [L]
Even
RewriteRule ^section/MusicTracks/search/(.*)\%2F(.*)$ cgi-bin/file.cgi?Operation=ItemSearch&SearchIndex=MusicTracks&Keywords=$1 [L]
RewriteRule ^section/MusicTracks/search/(.*)\%2F(.*)\%2F(.*)$ cgi-bin/file.cgi?Operation=ItemSearch&SearchIndex=MusicTracks&Keywords=$1 [L]
doesn't work.
A couple of points, though:
1) In all cases, I'm seeing encoded slashes as lowercase, i.e. %2f.
2) Your use of ".*" -- the most 'greedy' and most ambiguous pattern, may be contributing to your trouble.
Fixing both problems makes your longest rule look like this:
RewriteRule ^section/MusicTracks/search/([^/%]+)(/¦\%2f)([^/%]+)(/¦\%2f)(.*)$ cgi-bin/file.cgi?Operation=ItemSearch&SearchIndex=MusicTracks&Keywords=$1 [NC,L]
Note that I added two parenthesized subexpressions in order to match "/" or "\%2f", so your back-reference numbering will have to take that into account if you intend to capture two or more parameters. I also used forward-looking negative matches to speed up the processing, i.e. "[^/%]+" means, "match one or more characters not equal to a slash or a percent sign." This is much, much faster that using ".*" because the parser will only have to process the pattern in a forward direction. Using ".*" would force it to process your string many, many times, and is very inefficient.
The percent sign should not have to be escaped within [] but it does have to be escaped within ().
Replace the broken pipe "¦" characters with solid pipes before use!
Jim
On a U.S. 101-key keyboard, the pipe character is located above the right shift key, and would be accessed with Shift plus \ key.
It is ASCII code %7c (hexadecimal), also called a vertical bar.
mod_rewrite requires the character-code of %7c, but posting on WebmasterWorld changes it to some other code -- and trying to use that other code will cause mod_rewrite to fail with a 500-Server Error.
Jim