Creating and Using .htaccess
A Quick Tutorial
A word of caution before we start. You will be creating the most powerful file on your entire website with this tutorial (assuming it ends up in your uppermost/root folder). See the story related in "The Saga" on how I made our entire site inaccessible for a minute or so because of one character — an exclamation point (!). Also, if you use FrontPage (ugh) as your HTML editor and you use FrontPage "extensions" on your site to manage it, creating/editing .htaccess files can break FP extensions — or so I've been led to believe. If you are FP dependent, I can't help you. Go learn HTML and do things the correct way, with a text editor. You can do much more with .htaccess than what is described in these several pages: password protection, file/folder redirection, denial of access based on IP, serve custom error pages, determine site behavior based on user agent, query string, referrer, requested URL, and much, much, more. The code presented on these pages is currently installed and working on troop53.net. Depending on server setup it may or may not work on your server. If you decide to further explore the capabilities of .htaccess you're on your own. So, let's get started!
First and foremost you must have a decent text editor. You cannot use Word, WordPad, or another word processor even though they can open and write to text files. Word processors throw in odd characters, headers and line returns that are incompatible with .htaccess and will cause unpredictable behaviors ranging from just plain not working to making your site inaccessible and unusable. Windows NotePad is barely adequate but if you must you can use it. I highly recommend either EditPad Lite or Edxor. Both of these freeware text editors are excellent for creating and editing text, HTML, CSS, XML, perl, .htaccess and other text-based files. I'll wait here while you go download and install one.
Back yet? Alright, let's create your .htaccess file.
That wasn't so hard, was it? Now we need to upload your new .htaccess file to your website. Uploading will be somewhat dependent on your FTP software, so I won't give you step-by-step instructions. .htaccess must be handled as a text file so make sure you upload it in text (ASCII), not binary, form. If your FTP software won't upload the file because of its name, rename your local copy to htaccess.txt, upload to your site, then rename it to .htaccess on the server using your FTP software.
As to what folder to put it in, try your uppermost, or root folder first. If you find that the above ruleset interferes with other scripts you may be running, move it to your Plans installation folder. Remember that a .htaccess file affects the folder it resides in and all folders within that folder. It will have no effect on folders above it or "sideways" to it.
Things not working? Break your site? Some things to check:
To wrap up
Now you're an expert! Well OK, maybe not; I'm not either. But now that you know enough to be dangerous, let's move on to using .htaccess to "Bomb-proof" Plans against some annoyances.
|Disclaimer || Copyright © 2002-13 BSA Troop 53 || Privacy statement|