Archive for July, 2008

htaccess::How to Redirect the website

Tuesday, July 29th, 2008

There are many different ways of redirecting pages, through http-equiv, javascript or any of the server-side languages.You can do it through htaccess, which is probably the most effective, considering the minimal amount of work required to do it.

The main advantage of htaccess is it uses redirect to look for any request for a specific pageĀ  and if it finds that request, it forwards it to a new page that you have specified:

Redirect /olddirectory/oldfile.html http://yoursite.com/newdirectory/newfile.html

Note :There are 3 parts to that, which should all be on one line : the Redirect command, the location of the file/directory you want redirected relative to the root of your site (/olddirectory/oldfile.html = yoursite.com/olddirectory/oldfile.html) and the also the full URL of the location you want that request sent to. Each of the 3 is separated by a single space, but all on one line. You can also redirect an entire directory by simple using Redirect /olddirectory http://yoursite.com/newdirectory/

Using this method, you can mutiple number of pages no matter what you do to your directory structure. It is the fastest method that is a global affect.

How to Enable SSI Via htaccess

Tuesday, July 29th, 2008

You can enable SSI with htaccess. Before making any change you must take permission of your webhosting provider, because it can be considered ‘hacking’ or violation of your host’s TOS, so be safe rather than sorry:

1)AddType text/html .shtml (This line order the server that pages with a .shtml extension (for Server parsed HTML) are valid.)

2) AddHandler server-parsed .shtml (this line adds a handler, the actual SSI bit, in all files named .shtml. It order the server that any file named .shtml should be parsed for server side commands)

3) Options Indexes FollowSymLinks Includes (This line is just techno-junk that you should throw in there).

. The last

And that’s it, you should have SSI enabled. But wait…don’t feel like renaming all of your pages to .shtml in order to take advantage of this neat little toy? Me either! Just add this line to the fragment above, between the first and second lines:

If you are going to keep SSI pages with the extension of .shtml, and if you want to use SSI on your Index pages, you need to add the following line to your htaccess:

DirectoryIndex index.shtml index.html

The above command allows a page named index.shtml to be your default page, and if that is not found, index.html is loaded.