Filed in Product & Development by Jerry Schwartz | June 26, 2012 2:30 pm
We frequently update our products, and Cloud Files is no exception. In this series of technical posts, we'll dig into how developers using the Cloud Files API can leverage new capabilities in Rackspace Cloud Files.
You can now use your Cloud Files account to create a static website. First, you must CDN-enable a storage container. Any HTML or static web pages in the container will become available through a static website once you set the X-Container-Meta-Web-Index header to index.html or other index page of your choice. You may also create subdirectories in your website by creating pseudo-directories, as outlined in the pseudo directory section of this guide. Each pseudo-directory becomes a subdirectory in the website.
The page you set for X-Container-Meta-Web-Index becomes the index page for every subdirectory in your website; each pseudo-directory should contain a file with that name. So, if you set X-Container-Meta-Web-Index to index.html, you should have an index.html page in each pseudo-directory. If you do not have the named index page, visits to myhost/subdir/ will return a 404 error.
curl -X POST -H "X-Container-Meta-Web-Index: index.html" -H "X-Auth-Token: 19264db3-c845-40ea-86ed-8a33d89bfe00" "https://storage101.dfw1.clouddrive.com/v1/MossoCloudFS_a55df/MyLibrary/
Once your container is configured for Static Web and your domain host has your CNAME recorded, you will get the following results.
container/index.html container/page2.html container/subdir/index.html container/subdir/pageX.html
In the results below, the user’s CNAME is myhost, and the X-Container-Meta-Web-Index is set to index.html. The results on the right of the example are the pages that display in the Web browser.
http://myhost Displays container/index.html http://myhost/page2.html Displays container/page2.html http://myhost/subdir Displays container/subdir/index.html http://myhost/subdir/ Displays container/subdir/index.html http://myhost/subdir/pageX.html Displays container/subdir/pageX.html
This is just one of many new features in Rackspace Cloud Files that developers can take advantage of. Cloud Files customers are urged to try out this new feature in their next API project or add it to a current application. If you're not yet using Cloud Files, sign up for an account and check it out. And now, using Cloud Files is more affordable since we reduced the cost of Cloud Files by 33 percent.
Source URL: http://www.rackspace.com/blog/rackspace-cloud-files-how-to-create-a-static-website/
Copyright ©2013 The Official Rackspace Blog unless otherwise noted.