The .htaccess they never tell you

There is one simple use for an .htaccess file that none of the books or online tutorials or references ever seem to tell you, and it is the one thing that I always find myself wanting to do.

Simple Redirect

Redirect from http://www.mywebsite.org to http://www.mywebsite.org/something/

Recently I have had to recreate from scratch a number of websites – sure the hosting company had full backups but theitr timescales were radically different from mine, so yes there is a website, but there sure as hell isn’t any content.

So like any good web person I reinstalled from my own backups, which for some unfathomable resaon had every file, execpt for the .htaccess files which I had to rewrite on the spot.

So here it is simple and effective, but so so elusive, type the following into a text editor, save the file as .htaccess and FTP it to the root of your website.

RewriteEngine on
RewriteBase /
RewriteRule ^$ blog/
RewriteRule index.html$ blog/
RewriteRule index.php$ blog/

Enable cgi scripts outside of cgi-bin

This assumes that you do not have access to Apache httpd.conf file AND that the your setup allows you to override server settings with .htaccess . Again create and save an .htaccess file.

Options +ExecCGI
AddHandler cgi-script cgi pl

This has come in very useful installing a copy of Movable Type for a friend

And the useful links that I have found on my travels

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>