Archive for December, 2004

Force Use of WWW in URL

Friday, December 17th, 2004

This small tutorial will show you how to force the use of “www” in you URL.

How many sites link to your site without the “www”? Consolidate you page rank and links by forcing the use of one host name.

You will need Apache and mod_rewrite for this to function properly. Create an .htaccess file and place the following commands in it. If you already have an .htaccess file then simply update it.

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.casualcode.com
RewriteRule (.*) http://www.casualcode.com/$1 [R=301,L]

You will need to obviously change “casualcode.com” to your own domain.

The status code of the redirection is 301 Moved Permanently. A 301 redirect is the safest redirect because it helps preserve search engine ranking and page rank. Redirection should be setup properly on you web site now.

mod_rewrite is an Apache module which uses a rule-based rewriting engine, based on regular expression, to manipulate requested URLs on the fly.

Update

Google now has a feature for you to set the preferred domain in Google webmaster tools.

UNIX Command Cheat Sheet

Friday, December 17th, 2004

A list of unix commands for basic unix command reference. Most of these unix commands will work on the linux command line. However, very few of these commands will work on Windows unless you have the proper tools install.

(more…)

Browser Dependent Cascading Style Sheets (CSS) in PHP

Friday, December 17th, 2004

Everyday webmasters are learning more about making tables-less web designs. Some problems they face are incompatibilities between browsers. If you can make a CSS layout look consistent in Internet Explorer and Mozilla Firefox , then you have done well. Believe it or not, people are still using the “stone age” version 4 of Netscape Navigator which has horrible CSS support. (more…)

Page Loading Time in PHP

Friday, December 17th, 2004

Learn how to output the time a page takes to load.

Have you every wondered how sites get that “Page loaded in x.xxx seconds.” at the bottom of there pages? It is very simple to do and can be done with any server-side scripting language. I will show you how to do it in PHP.

The script is very simple. First it gets the micro time as the start time. Then at the end it gets the micro time again and finds how many micro seconds have past.

Place this code at the top of your page:

Place this code at the bottom of your page:

Stop Directory Listings on Apache

Friday, December 17th, 2004

This tutorial will show you how to stop directory listings on an Apache web server. Removing the directory listings will make your website much more secure. You can stop directory listings by editing a simple file called “.htaccess”.

Start a new document is you favorite text and save it as “.htaccess”. If you would like to stop directory listings type the following in the text editor.

Options -IndexesIf a file called “.htaccess” already exists in your web root then you will need to edit the current file. Once your “.htaccess” file is upload Apache will no longer show your directory listings.

Alternatively, if you would like to show directory listings type this into you “.htaccess” file.

Options +IndexesDirectory listings can pose as a security threat. Only allow directory listings if you know what you are doing.

Create a Favicon

Friday, December 17th, 2004

You are probably wondering what a favicon is. It’s a widely supported feature in most modern browsers that allows a site to specify a small graphics or icon to go next to the address in the address bar. Favicon are also used when you bookmark pages with Internet Explorer. For some reason IE occasionally has a problem with favicons. Mozilla, on the other hand, utilizes favicons perfectly. (more…)