0

I am working on a website and noticed that as I was making up folder names that any folder name that begins with a # is not recognized from the web browser. For example: example.com/#example/index.html will not work. Whereas example.com/%23example/index.html works. In the same example using !@$%*& will work file without encoding. Curious why and how to make it work if I wanted it to. I read this article: Which characters make a URL invalid?. Thanks

Community
  • 1
  • 1

1 Answers1

0

Invalid characters might have a special meaning for the browser. For example # is used to create links on the same page. Take a look here.

Community
  • 1
  • 1
  • the link i referenced said that # is not a invalid character. As a directory folder I have not seen where its invalid either. – Trainingday Aug 17 '16 at 16:12
  • # is valid, but it has a special meaning. It indicates that link leads to an anchor(id="anchor") on the page. So if you use example.com/#example/index.html the browser is trying to find the id="example..." on the page example.com/index.html. – Michael Scheffenacker Aug 17 '16 at 16:22
  • so why would example.com/%23example/index.html work? Its the same thing in my head. I know its encoding but its just converting the # so its the same folder. – Trainingday Aug 17 '16 at 17:46
  • The explicit character # has a special meaning for the browser, while using %23 allows you to use this character if needed without the special meaning. I a lot of programming languages you have characters with a special meaning, for example \, you might not be able to use it directly, because it introduces a control sequence. But you can use \\ to generate a single back slash in a string. It is pretty much the same concept. – Michael Scheffenacker Aug 18 '16 at 08:11