Every time we surf the web, we specify a URL (Uniform Resource Locator) in a browser in our client computer to send a request to a web server. HyperText Transfer Protocol (HTTP) is used to send the request and receive the response(s). To host a site, a different protocol, FTP (FIle Transfer Protocol) is used to transfer the site files from a development host machine to a server. The files are then available to an HTTP request sent by a URL in a browser.
HyperText Transfer Protocol (HTTP)
HTTP is a simple protocol with few words, GET, POST, DELETE, and PUT. This is the protocol you use to surf the web; clicking a hyperlink or submitting an HTML form in a browser uses HTTP to send a request to a server and the server responds with the requested documents or an error status (such as, 404 - Not Found).
Exercise — Client – Server
To ss the request / responses for this page:
- In Firefox, click on this element and Inspect Element(Q)
- Opent the Network panel.
- Refresh this page to send a request.
- Notice the Type and the time taken for each response.
- On receiving the responses, the browser compiles the document and displays it.
File Transfer Protocol (FTP)
FTP is a network protocol for transferring files from one host to another host over a network such as the internet. In practice this involves:
- connecting to a server,
- logging in,
- transfering files.
This can be done using an FTP program with a comman-line or a graphics user interface. Web browsers and operating system file browsers are also FTP client programs and accept FTP commands such as,
ftp://ip address to connect to a server. You can then host your site by dragging and dropping files from the local host to the remote server. Befor that, please follow the Preparing a site to host section meticulously, it will save you time!
Preparing to host
Testing and validating the code in a development system is essential before uploading to a web server.
Test the site locally
For valid documents once uploaded to the server, the most likely problem breaking your site is the pathnames used in your code. Avoid absolute pathnames.
Absolute pathnames start with a logical drive name such as C: or I: or / (top level of the current disk). These are local logical drive names that do not exist on the remote server. The HTML elements that have attributes that require a pathname include
link, a, img, sound and
video Check, these all have relative pathnames and follow a naming convention. For example, in these exercises we used relative pathnames and followed a consistent naming convention.
We specified all files and directory names in lower case with underscore instead of space characters. We have one wd directory with all the files in this directory; a relative path is then simply the filename.
Exercise — Preparing to host
- Follow the simple naming convention; check all filenames are in lower case with underscore instead of space characters.
Check the HTML
link, a, img, soundand
videoelements and specify relative pathnames. WIth all files in the same directory, the relative pathname is simply the filename.
- Validate the HTML and CSS code; use the W3C HTML validator and the W3C CSS validator.
- Check each page display in a browser.
Hosting a site
Hosting a site involves:
- Preparing a site to host.
- FTP connection to a server using its IP address.
- Logging in to the server.
- Transfering files
- Browsing to site URL.
Exercise – Hosting a site
- Open "My Computer" in windows or a shell in Linux to FTP to the server. In the top window showing the current directory type: ftp://your_server_name
- Once connected you are normally asked to login.
- Once logged in, change directory to the root directory of your site; typically named webpages or public on many ISP hosting.
- Drag from your local system and drop in the window connected to the server.
Use Firefox to browse to the site URL.
On a shared server, the URL can seem counter intuitive. A general address,
http://your_server_name/~c1234/index.html, translates to the user, ~c1234's web directory, typically named, webpages or public. This directory is then searched for the file index.html.
So, while the site is uploaded using an ftp session starting with
ftp://your_servername, the site is typically surfed to with a URL,
- Should the site not display as expected, visit the Preparing a site to host.