for example suppose I have a file "test index.html" and I want to set this as the index document for static website hosting, how do I do this? I've tried test index.html, "test index.html", test+index.html, test%2Bindex.html e

  • 5
    Just for background, why exactly is it important that you want to do this? Why can't you do index.html like virtually every other static website uses?
    – Tim
    Apr 2, 2017 at 1:22
  • 2
    Agreed. Spaces and HTML URLs don't get along well, and will only serve to make things difficult for your users.
    – EEAA
    Apr 2, 2017 at 1:25
  • I have multiple test copies of the index, i happened to put a space in the name. Why have a box to specify the name at all if index.html is "virtually" the only way?
    – penchant
    Apr 2, 2017 at 1:45
  • 3
    There are literally millions of options for you to choose other than index.html that don't include a space in the name. Just rename the file.
    – EEAA
    Apr 2, 2017 at 2:04
  • 1
    I'm voting to close this question as off-topic because it's completely ridiculous.
    – Wesley
    Apr 2, 2017 at 4:19

2 Answers 2


As of RFC3986 dictates:

URL encoding replaces unsafe ASCII characters with a "%" followed by two hexadecimal digits. URLs cannot contain spaces. URL encoding normally replaces a space with a plus (+) sign or with %20.

The relevant extracts about URL encoding can also be found at w3schools.org

  • neat. How do I make use of this with regards to what my question is asking, specifically, with aws s3 static website hosting configuration using the aws console? neither %20 or + seem to work
    – penchant
    Apr 8, 2017 at 0:16
  • The answer is not a solution, but the proof that depicts your approach to the problem is wrong from start due to the fact that spaces (among other characters) are not supported in URLs and must be removed or escaped. If you want a direct solution, rename your files in S3 to remove special characters or, as many others have said along this thread, use escaped characters in your URL to bypass the limitations of the URL syntax.
    – ma.tome
    Apr 8, 2017 at 9:25

You would need to edit the webserver config and specify the index document. Your attempt to modify that directive was correct, you just used the wrong syntax - %20 is the URL code for a space - so instead of test%2Bindex.html it would be test%20index.html

Or, if you are trying to get to it for testing purposes, then protocol://example.com/test%20index.html ought to get it (or it does on my local apache install)

  • which webserver are we talking about? this is an s3 bucket static website configuration set in the aws console.
    – penchant
    Apr 2, 2017 at 2:01
  • The index document directive is available on most webservers - it sets the file name that the server tries to locate if a request only specifies a directory in the URL. It can be a list of files, in an order of preference. From the wording of your question "set this as the index document" I assumed you have access to the web server configuration... If you do not have this access you'll have to use whatever the sysadmin has specified as default choices, OR include a file name with every URL.
    – ivanivan
    Apr 2, 2017 at 2:04
  • @ivanivan your answer is incorrect. This is about Amazon S3, not a web server.
    – Tim
    Apr 2, 2017 at 2:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.