I'm currently working on a website built by a previous developer.
This website has previously sent links to subscribers with spaces in the url filenames, for example http://website.com/docs/this is a pdf.pdf
. I have now fixed these links as they are generated by using php url encoding when the link is generated, because specifically internet explorer users are not finding the file on the linux server because the filename has spaces in it (chrome and FF work by properly inserting %20 into the spaces in the url).
I'm currently trying to find a way to use .htaccess to rewrite these urls that have spaces in them to redirect to the correct url. For example, if a user were to request http://website.com/docs/this is a pdf.pdf
the .htaccess will redirect to http://website.com/docs/this%20is%20a%20pdf.pdf
. Note that there are thousands of documents on this server so this does need to be dynamic.
WHAT HAVE I TRIED?
I've looked at this and this and more, but can't add more links because SO says I don't have enough reputation.
These options seem to show that it is possible if you know in advance what the filename will be. I need this to be dynamic. Anyone out there have any ideas?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…