urlhyperlinkurlencodehashtag

hash tags in urls and hyperlinks


I created a hyperlink to a file. the file name contains hashtags as a means to separate information.

<a href="upload/1427853638#0#file#A101.pdf"><div style="height:100%;width:100%">.</div></a>

translated to...

http://localhost/dir/upload/1427853638#0#file#A101.pdf

Is this a "legal" name in a URL? Im getting a "file not found" error

The requested URL /dir/upload/1427853638 was not found on this server.

So, clearly the # has another meaning in the URL (I understand now, its a location hash property). Is there a way to get this to work, or do i need to use another character besides the # in the file names?


Solution

  • Since # is a special character in the URL semantic (it's used to provide an internal anchor in a HTML page), it should be URL-encoded into %23.

    Your URL should be: http://localhost/dir/upload/1427853638%230%23file%23A101.pdf.

    NB: you can find an online URL encoder here: http://meyerweb.com/eric/tools/dencoder/