By Doug Addison
Book Price: $39.99 USD
£28.50 GBP
PDF Price: $31.99
Cover | Table of Contents | Colophon
#).LoadModule includes_module libexec/httpd/mod_include.so
AddModule mod_include.c
AddType text/html .html AddHandler server-parsed .shtml
AddHandler server-parsed .shtml .html
DirectoryIndex entry in your httpd.conf file, or a specific direc-tory's .htaccess file. List the files that should be treated as default pages in the order you wish them to be served:DirectoryIndex index.php index.html index.htm index.php3 welcome.html
DirectoryIndex index.php index.html index.htm index.php3 welcome.html
nslookup or dig, either on your own PC or through a Telnet shell provided by your hosting account, you can investigate the details of the various listings in your DNS record without changing them. Some web-based tools (see the "See Also" section in this Recipe) can access the same DNS record information if you do not have access to dig or nslookup.dig request on
www.daddison.com shows it to be a CNAME, or canonical name, listing for daddison.com. A CNAME listing is an alias to the main, or A RECORD, listing in the domain name's DNS record. Requests for either web site address—with or without the "www"—are answered with my web site:Lookup has started … ; <<>> DiG 9.2.2 <<>> www.daddison.com any ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40212 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 1 ;; QUESTION SECTION: ;www.daddison.com. IN ANY ;; ANSWER SECTION: www.daddison.com. 3600 IN CNAME daddison.com. ;; AUTHORITY SECTION: daddison.com. 3600 IN NS ns22.pair.com. daddison.com. 3600 IN NS ns0000.ns0.com. ;; ADDITIONAL SECTION: ns0000.ns0.com. 7110 IN A 216.92.61.2 ;; Query time: 98 msec ;; SERVER: 151.164.20.201#53(151.164.20.201) ;; WHEN: Wed Apr 20 15:50:18 2005 ;; MSG SIZE rcvd: 113
cron, to do the work for you.cron that can do everything from executing simple file operations—like copying an updated web page from a private directory to a public one—to running complete scripts with instructions for more complex site maintenance routines. Let's look at the basics of cron and how you can use it to do simple site updates when you're otherwise busy having a life.cron to the rescue!cron will be able to find and move the file when the time comes.apachectl graceful command, or the appropriate restart command for your web server.apachectl. With it, you can start, stop, and restart the HTTP daemon on your dedicated server or "virtual server" account.apachectl at the command-line prompt to your web server by typing its name followed by a space and stop, start, or graceful. If that does not work, you will have to specify the full path to the script. To locate the script on your server, use one of these commands:find / -name apachectl
which apachectl
apachectl stop and apachectl start are self-evident.tail
grep
ps
http://www.godaddy.com). When choosing a registrar for the site, make sure you can "park" the domain on their DNS servers for free (or a nominal fee) and forward requests for the domain to another URL. In addition to free parking and forwarding, GoDaddy also lets registrants "mask" the forwarded domain, which means that the browser location window will always display the domain name (mkdir command. A full-featured FTP client or WYSIWYG site management applications should offer a menu command for creating directories on a remote server as well.%20. Likewise, avoid special characters: The server might mistake ampersands (&) and questions marks (?) for delimiters in a CGI script argument; the number (or pound) sign (#) is used in HTML markup to create a link to another section of the same web page. Hyphens and underscore characters are safe, but—as you saw in Recipe 1.1—they add an unnecessary stumbling block to people trying to memorize a URL or recite it over the phone. Best to leave them out, if possible. Finally, use all lowercase; on Unix servers, the directory and filenames that make up a URL are case sensitive.<title> tags in your web page code and follow it throughout your site. The title goes in the head section of the HTML code, like this:<head> …meta tags… <title>page title information</title> …CSS styles and other head content… </head>
$temp), perform a calculation on the variable to convert it to Celsius, and then echo the same variable (with a new value) back to the user.$temp has several disadvantages (that's why I chose it). As a generic abbreviation for temperature, $temp easily could be misconstrued as representing a temporary value (or the user's temperament) by another programmer reviewing the code.$temp meets the simple needs for a hypothetical temperature converter, it becomes woefully inadequate as soon as you try to add other functionality to the converter. Say, for example, that you improve the script to accept two temperature values from a user—the current indoor temperature and the current outdoor temperature. Which one of the two should be $tempwget to mirror the files on the server to another location either by HTTP with this command:wget --mirror http://yourwebsite.com
wget --mirror ftp://username:password@yourwebsite.com
wget, you can perform heroic feats of webmastering, whether it's copying a single file from one site to another, or an entire site to another server.wget will only copy files it finds links to. Unused images and old web pages still lingering on the server will be skipped. Using FTP, wget will copy everything.wget can be indispensable include:src attribute. (Perhaps the other site's server is slower or less reliable than yours, or outside linking to the image has been disabled, as described in Recipe 5.5.) With wget, you can specify the URL of the file, a local directory on your server where it should be copied, and the number of times to retry a flaky HTTP connection. Combined with cron (see Recipe 1.8), wget can perform its connect-and-copy task as often as you (or your system administrator) want it to.wgetmod_rewrite rules in an .htaccess file to invisibly turn simple URLs into complex query strings that return dynamic pages to the visitor's browser. For example, an e-commerce site that sells men and women's clothes might offer a variety of men's shoes, such as boots, oxfords, sandals, and loafers.http://mensandwomensclothes.com/store/list.php?type=mens&cat=shoes&subcat=loafers
http://mensandwomensclothes.com/store/mens/shoes/loafers/
RewriteEngine On Options +FollowSymLinks RewriteRule ^(.*)/(.*)/(.*)/$ /store/list.php?type=$1&cat=$2&subcat=$3
mod_rewrite module has been compiled into your installation of Apache (typically, it has), the first line (RewriteEngine On) prepares the module for the rewrite rule or rules to follow. The second line (Options +FollowSymLinks) can be left out if it's already in the main Apache configuration file (typically, httpd.conf).