Adding Google Maps to your webpage Using htaccess to password protect your site the easy way
Jul 21

If you are new to apache and/or webservers, here are a couple of things in addition to our .htaccess tutorial which you may find of use. As always, please feel free to ask if anything is not clear or you would like any help.

Allow URLs to be case-insensitive.
If you’ve made the switch to Apache from Internet Information Server (IIS), one of the first things you’ll notice is that Apache matches URLs with case sensitivity. This can be a problem for websites that were built for IIS, but were migrated to apache. A simple solution is to enable mod_speling using the –enable-speling directive when configuring Apache.

Then be sure to include the following directive in your Apache configuration file:

CheckSpelling On
What mod_speling (yes - it is spelled “speling”) attempts to correct misspellings of URLs that users might have entered, by ignoring capitalization and by allowing up to one misspelling. It attempts to locate files that were spelled improperly, and in doing so, checks for upper- and lower-case equivalents of files.

Automatically redirecting to https / SSL.

Users may forget to include the https:// in front of a URL when accessing a secure site. You can force them to redirect using the RewriteCond and RewriteRule directives. This is particularly useful on shopping cart sites.

First, use RewriteCond to make sure the user actually did forget to include https, and is still connecting through unencrypted port 80:
RewriteCond “%{SERVER_PORT}” “^80$”
Then, if the condition is true, the RewriteRule below will force the request to use SSL:
RewriteRule “^(/shop/.*)” “https://%{HTTP_HOST}$1″ [R, L]

Deny other servers from accessing your files

If you have some popular files or images on your site, other webmasters may link directly to them, in an attempt to save bandwidth on their own sites. Fortunately, you can prevent this occurrence by following the example below, which restricts access to all GIF or JPG files from requests that come from any domain other than your own:
<FilesMatch “\.(gif|jpe?g)$”>
SetEnvIf Referer “^http://([^/]*\.)?mydomain.com/” request_ok = 1
Order Allow, Deny
Allow from env=request_ok
</FilesMatch>

You can place this group inside your Apache config file, a virtual host group, a directory group, or even an .htaccess file in the root of your site.

You may also want to look at this previous post:

Using .htaccess to forward domain.com to www.domain.com

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Technorati
  • BlinkList
  • Live
  • Reddit
  • Slashdot
  • StumbleUpon

Technorati Tags: , , , , , , , , , , , , , , , , , , ,

One Response to “Top Apache tips for webmasters”

  1. Olkenava » Blog Archive » 3 Top Apache tips for webmasters UNITED KINGDOM WordPress wordpress Says:

    [...] read more | digg story [...]

Leave a Reply