I have a directory with PDF files that I need to create an index for. It is a PHP page with a list of links:
<A HREF='path to file'>filename</A>
The filenames can be complicated:
LVD 2-1133 - Ändring av dumpningslina (1984-11-20).pdf
What is the correct way to link to this file on a Linux/Apache server?
Is there a PHP function to do this conversion?
You can use rawurlencode() to convert a string according to the RFC 1738 spec. This function replaces all non-alphanumeric characters by their associated code.
The difference with urlencode() is that spaces are encoded as plus signs.
You’ll probably want to use the last one.
This technique is called Percent or URL encoding. See Wikipedia for more details.