<p>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:</p>

<pre><code>&lt;A HREF="path to file"&gt;filename&lt;/A&gt;
</code></pre>

<p>The filenames can be complicated:</p>

<pre><code>LVD 2-1133 - Ändring av dumpningslina (1984-11-20).pdf
</code></pre>

<p>What is the correct way to link to this file on a Linux/Apache server?</p>

<p>Is there a PHP function to do this conversion?</p>

[{'answer_id': 35046, 'author': 'Andy', 'author_id': 1993, 'author_profile': 'https://Stackoverflow.com/users/1993', 'pm_score': 0, 'selected': False, 'text': '<p><a href="http://se.php.net/manual/en/function.urlencode.php" rel="nofollow noreferrer">urlencode()</a> should probably do what you want.</p>\n\n<p><strong>Edit</strong>: urlencode() works fine on swedish characters.</p>\n\n<pre><code>\n    &lt;?php\n        echo urlencode("åäö");   \n    ?&gt;\n</code></pre>\n\n<p>converts to:</p>\n\n<pre><code>\n    %E5%E4%F6\n</code></pre>\n'}, {'answer_id': 35048, 'author': 'Anders Sandvig', 'author_id': 1709, 'author_profile': 'https://Stackoverflow.com/users/1709', 'pm_score': 0, 'selected': False, 'text': '<p><a href="http://en.wikipedia.org/wiki/Url_encoding" rel="nofollow noreferrer">URL encoding</a>. I think it\'s <code>urlencode()</code> in PHP.</p>\n'}, {'answer_id': 35052, 'author': 'Javache', 'author_id': 1074, 'author_profile': 'https://Stackoverflow.com/users/1074', 'pm_score': 3, 'selected': True, 'text': '<p>You can use <a href="http://php.net/manual/en/function.rawurlencode.php" rel="nofollow noreferrer">rawurlencode()</a> to convert a string according to the RFC 1738 spec.\nThis function replaces all non-alphanumeric characters by their associated code.</p>\n\n<p>The difference with <a href="http://php.net/manual/en/function.urlencode.php" rel="nofollow noreferrer">urlencode()</a> is that spaces are encoded as plus signs.</p>\n\n<p>You\'ll probably want to use the last one.</p>\n\n<p>This technique is called Percent or URL encoding. See <a href="http://en.wikipedia.org/wiki/Url_encoding" rel="nofollow noreferrer">Wikipedia</a> for more details.</p>\n'}, {'answer_id': 35058, 'author': 'Rob', 'author_id': 3542, 'author_profile': 'https://Stackoverflow.com/users/3542', 'pm_score': 0, 'selected': False, 'text': '<p><a href="http://php.net/manual/en/function.rawurlencode.php" rel="nofollow noreferrer">rawurlencode</a> will encode "exotic" characters in a URL.</p>\n'}, {'answer_id': 35077, 'author': 'Peter Olsson', 'author_id': 2703, 'author_profile': 'https://Stackoverflow.com/users/2703', 'pm_score': 1, 'selected': False, 'text': "<p>The urlencode() function will convert spaces into plus signs (+), so it won't work. The rawurlencode does the trick. Thanks.</p>\n\n<p>Be sure to convert each part of the path separately, otherwise path/file will be converted into path%2Ffile. (which was what I missed)</p>\n"}]
['https://Stackoverflow.com/questions/35037', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2703/']