|
Understanding the web site file system:
index.html and why you should use it:
This again is where a
number of newer webmasters become stumped. They
upload all of their files and directories, and then
want to access them with their browser, but forget
to name their home page index.html. Here's what
happens: they access their site as http://www.mydomain.com,
and what they see is their entire file directory
structure! Yikes!… It looks just like exploring the
C drive on your computer! You don't want visitors
seeing that, do you?
When you access your site by calling it as http://www.mydomain.com
the web server looks for the "index.html" file as
the default file to be sent to visitors, and thus
this is why http://www.mydomain.com
by itself will automatically display the home or
welcoming page. It's because the server
automatically looks for index.html whenever a domain
or directory is called without a filename appended
to it such as this, http://www.mydomain.com/filename.xyz
If it can't find index.html, it will simply list
"your entire web directory" to everyone that
accesses it, which can be a security risk. You
should use an "index.html" file in any directory you
create, including your "root" web directory. In
general, it's always a good idea to use "index.html"
as your main page in all sub-directories on your
account. Forgetting to place an index.html in your
root web, or any subdirectory of your web for that
matter will effectively leave all of its contents
viewable to the world.
However, it is possible to specify the default
webpage that visitors see when visiting any of your
directories (e.g. http://www.mydomain.com/fun
, http://www.mydomain.com/contact
, etc.). To do so, you need to create a file called
".htacess" in that directory. Then, just open up
that file and add the line
DirectoryIndex filename.xyz
where filename.xyz is the name of the page you want
to load by default when someone accesses that folder
with a browser. (Note that the file name is case
sensitive.) Make sure to save the changes you made
to the file.
For example, say you have a page called "home.html"
that you want to have load by default when someone
goes to http://www.your_domain.com . Just create a
new file called ".htaccess" in your /public_html
folder and add the line
DirectoryIndex home.html
to it. Now, when someone goes to http://www.your_domain.com
, your home.html page will load by default. As
another example, say you have another page called
silly.html that you would like to load by default
when someone goes to your http://fun.your_domain.com
subdomain. Just create a new file called ".htaccess"
in your /public_html/fun folder and add the line
DirectoryIndex silly.html
to it. Now, when someone goes to view http://fun.your_domain.com
(or http://www.fun.your_domain.com, they're the same
thing) in their browser, your silly.html page will
load by default.
Understanding case sensitivity:
Another small detail,
which can throw many newer users into a tailspin.
Unlike your local PC, the Unix file system is very
particular about "uppercase" and "lowercase" file
names. Therefore, if you were to install a script,
(let's say the wwwboard discussion forum) for
example), the name of this script would be
wwwboard.pl. If you name a file picture file called
me.jpg, then this is what you must call it as.
Naming it me.JPG for example, (observe the
uppercase) tells a Unix web server to treat it as a
totally different file name.
Unix file servers are exceptionally fussy on this
issue, so make sure you pay close attention to case
when uploading files, or installing and configuring
cgi based scripts. The same rule applies for all
files including your .html pages. Again, the server
treats .html and .HTML as two entirely different
files. Want to keep in simple? Try to stick with
lowercase letters in all file names and extensions.
Uploading your files
in the correct mode (ASCII or Binary)?
Uploading in the wrong format for images or binaries
will result in a strange mess appearing in place of
the file. For CGI scripts, this mistake has to be
the most common cause of that annoying error known
as the (Server 500 Error - Malformed Headers), or
something to that lovely extent. While this can be
the result of many various programming errors, the
most popular amongst new users are uploading their
scripts in the "WRONG" format. Your cgi scripts
"MUST" always be uploaded in ASCII mode.
Alternatively, if you upload an image or .exe file,
it must be done in "BINARY" mode.
The difference between
ASCII and BINARY?
In short, html or text based files are supposed to
be transferred in ASCII mode. Uploading them in
Binary mode will append ^M's to the end of every
line. In most cases this is OK with html files,
because your browser will ignore them. BUT, with
other text files such as cgi scripts, uploading them
in binary will damage them, thus causing a (server
500 error). This is because binary mode has added
^M's to the end of every line, which are not
supposed to be in the program. This of course, is
what causes the additional message of (Malformed
Headers), which often displays at the bottom of the
"Server 500" message when a CGI script has crashed.
Once again, BINARY mode is used for transferring
executable programs, compressed files and all
image/picture files. If you try to upload an image
in ASCII mode, you will observe a strange mess
appearing on the page where the image is supposed to
appear. ASCII mode in this case, has corrupted the
binary coding in the jpeg or gif image. If this
happens, just re-upload it in the Binary format
Setting your FTP client to automatically
detect ASCII and Binary file transfers:
Most FTP programs have "AUTO" mode, which will tell
the FTP client to automatically detect the file type
you're transferring and will select the appropriate
mode. By default, most FTP programs will attempt to
transfer everything in binary mode, but when
"Automatic" is selected, the FTP client will check a
list of known ASCII extensions, (for example, .pl, .cgi,
.txt). If it detects one of these extensions, it
automatically switches to ASCII mode.
By Default, most of the well-known files to be
uploaded in ASCII are already entered, however you
can manually add additional extensions that you
would like to transfer in ASCII mode by selecting
the feature called "Extensions." Here, you can add
any additional extensions that will cause the FTP
client to toggle to ASCII mode automatically upon
detecting an extension entered in its list.
Remember, you must set your transfer mode to
"Automatic" for this to work.
File types and what they represent:
Various file types can effect both the behavior of
your files, as well as how the server treats them.
While there are numerous file extensions, which
represent a host of various file types, we'll stick
to the basic ones in this quick overview:
The .html file:
This is one is the most commonly used and the one
most of you are already familiar with. Html stands
for (hypertext Markup Language). Essentially, it
tells the server, as well as the hosting browser to
process and display the .html coding in a way, which
is meaningful to the end user through a browser.
The .htm file:
Many of you have probably noticed this newer
extension appearing in place of the traditional
.html one. In short, .htm is most often created, and
or generated from the Microsoft FrontPage web
editor. The two are essentially the same and provide
the same basic purpose. Unless you're using
FrontPage, you will probably use the .html extension
at the end of your web pages.
The .gif and .jpg
file:
Most commonly used because of its good compression
in web page images. Generally, .gif files are the
fastest loading, as they remove a lot of
information, which is not required to maintain image
integrity, but to a point however. .jpg will allow
more flexibility in compression and quality
settings, however it can also result in larger
files.
The .CGI and the .pl
file:
.cgi and .pl are most often used for perl scripts.
Perl scripts are small text based programs, which
are executed on the server end, and will perform a
host of interactive functions for a web site. In
short, when a .pl or .cgi file is called, it tells
the server to process it using the "Perl
Interpreter." The Perl Interpreter understands the
programming within the script, and will perform the
set of sub routines, which will yield your desired
effect. This desired effect could be anything from a
simple web page counter, to more complex programs
such as discussion forums, e-commerce platforms, to
online auctions. In many cases, you can download
these "ready to go" scripts for free, and in others
you may have to purchase them.
FrontPage and FTP:
If you're planning on
using Microsoft FrontPage to manage your web site,
there are a couple of issues or things you may want
to keep in mind:
There are two worlds. The General Unix hosting
world, and the Microsoft world. While this is not
necessarily a bad thing, Microsoft had indeed
decided to play by its own rules. As a result,
FrontPage does not always conform to the rules of
Unix, so you should be extremely careful when
accessing a FrontPage web via FTP. It's easy to
damage the FrontPage web, as well as it's associated
server extensions, and if it happens, you may loose
the ability to administrate it from your FrontPage
Explorer. To avoid problems like this:
- Do not alter, or
delete files that are part of a FrontPage web
- Do delete, move, or
alter directories ending in _vtf. These are the
FrontPage extensions
The ultimate
solution:
If possible, try to create your FrontPage webs in
sub-directories of your root. For example,
http://www.yourdomain.com/home. This way, you
can safely FTP into your root account to perform
other tasks, while avoiding the FrontPage webs,
which are safely out of the way in their own
separate homes. Remember! DO NOT delete any folders,
which end in _vtf! This will kill your FrontPage
web, and we'll have to reinstall the extensions for
you.
Next:
Using CGI
programming:
|