Can ampersands be used in folder names on a web server?

1

I have a website which contains several folders, including one called:

bits & bobs

which contains a file called test.txt

However, when I try to navigate to the file, I get a "bad request" message: http://tinyurl.com/9ez6nb4

If I take out the ampersand, and simply call the folder bits and bobs then it works ok: http://tinyurl.com/9hacna4

I contacted my web host, Arvixe, who replied that it was "not standard convention" to use ampersands in folder names, and that they could not be expected to support it.

Are they right, or is it a bug with their system?

Urbycoz

Posted 2012-10-17T08:38:10.310

Reputation: 1 055

They are right in that it is not standard convention. However that does not mean it should not work, assuming you use proper encoding. This link might help with that.

– Hennes – 2013-09-07T23:21:56.453

Answers

1

It is never a good idea to use special characters other than a _ or - in folder names on a webserver as it will cause problems as you've found out. To reference a file with special characters you need to URL encode your link, e.g., /bits%20%26%20bobs/

A space is %20 and an ampersand %26

JoJo

Posted 2012-10-17T08:38:10.310

Reputation: 36

It doesn't seem to work, even when encoded: http://tinyurl.com/chhtzz6

– Urbycoz – 2012-10-17T09:09:07.303

So is it not possible to just remove the ampersand? I would actually agree with your hosts, as I've already said, you should really only use underscores and hyphens in your folder names. Some systems might allow certain other characters but it's best to keep it safe. Whereas we think an ampersand is just shorthand for the word and, it could be interpreted as a command by the server. – JoJo – 2012-10-17T13:45:36.957