htaccess file

1

Good morning, I need the URLs that are written with # the server automatically write them with% 23 which is the only way it works, some example with the htacces file? please.

    
asked by Daniel Garcés 19.05.2016 в 17:55
source

1 answer

0

Let's see, what you are putting with the characters # is very dark. I personally discourage them altogether (the best would be to use characters that are safe for a url and not have to escape anything, even if the frameworks banque you).

If you want to send that URL to the server (eg click on a link to download a file) I'll make it short:

No matter how you put it, a request to a url like link does not go to send NEVER the hash or what follows.

If you want to actually spit that URL from the server to the client, I recommend you use the functions usually called url encode . These are going to escape unfortunate characters like that in your expected% 23.

In short: there is nothing you can do in your .htaccess but it belongs to you in the software.

Let's see it in particular:

  • I understand that your browser accesses the "url" / search engine / # Recordings% 2FTigo. Learn this before you become quilombo: The server is only sending GET / seeker /. The server is answering some HTML code with JS (which makes the interactive part of the browser). The JS returned at some point is processing in its own way the value of location.hash , which contains "Recordings / Tigo". That way can be, call it, a call Ajax.
  • The server is returning results, and one of them seems to be an url with /camino/a/archivo/daniel#garces.mp3. When you try to access it (downloading it) you will realize that your server does not work because it tries to access / path / to / file / daniel. I do not know how you are getting this data but when embedding that value in the client's html, you should make sure to escape it first (javascript has decodeURIComponent () while php I think it has urldecode, but that depends on whether that data is returned inside an html fragment by ajax, or within a js or json fragment by ajax).
  • At no point did we enter the .htaccess because in advance we will NEVER receive such character #.
  • answered by 19.05.2016 / 18:18
    source