Reputation:
I have a small collection of text files on a server. The URLs look like this: http://mysite.com/My%20Text%20File.txt
I have a small PHP script that takes the text file URI as a parameter and converts the text file to JSON: http://mysite.com/json.php?file=/My%20Text%20File.txt
And I have a rewrite rule that makes it pretty: RewriteRule ^(.*).json$ /json.php?file=$1.txt
And it works great. Now the URI for the JSON is identical to the text URIs, except for the file extension. But if I have a text file with an encoded has in the name: http://mysite.com/Text%20File%20%231.txt
Apache has no trouble opening the text file. Similarly the "real" URI works: http://mysite.com/json.php?file=/Text%20File%20%231.txt
But the rewrite rule flubs it. So the "file" GET parameter that PHP sees is "/Text%20File%20" -- with the hash and after missing.
I could avoid files with hashes in the name, but I'm curious why the hash gets unencoded when other encoded characters do not, and I can't find any reference to this elsewhere.
Upvotes: 1
Views: 118