Website Designers and Webmasters

Dedicated to all the tasks Webmasters, Website Developers and Website Designers find themselves facing.

By: Ashton Sanders

.htaccess – AddHandler

Apr 19 2007

There is a very common problem when trying to upgrade sites made by “newbie” website developers or when you realize that html isn’t the only language on the internet, and you need to upgrade your site.

Problem:

You have a site where every page has a *.html or *.htm extension, and you want to add a dynamic, server-side programming language like PHP.

Solution #1:

Go through your entire site, and change every file name to a *.php extension. Then go through every page and correct all of the hyper links. Then do testing on your entire site to ensure that you haven’t missed any links. Also, if you know anything about search engine optimization and websites, you’ll know you need to create 301 redirects from your old pages to your new so that you don’t lose any Rankings you may have gained. Then you have more testing to do to make sure all of your 301 redirects work….

Solution #2

Add this one line of Code into your .htaccess:

AddHandler x-httpd-php5 .php .htm .html

That’s all it takes to add PHP to my html files?

Yep, that’s it. That little line of code has saved me hundreds of hours of work, and I’m sure it’s not as commonly known as it should be.

-Spread the Wealth
-Ashton Sanders

By: Ashton Sanders

Regular Expressions – Regex

Mar 31 2007

Filed under: htaccess

Regular Expressions (or Regex for short) is a language that I’ve been learning a lot about recently. I don’t have any useful tidbits for you as of yet, but I do have a couple very nice and useful links that can help you learn about regex:

Extensive Regex Tutorial

(Note: Regex is used a lot in htaccess.)

When I have more for you on this subject, I’ll put it in the sidebar
-Ashton Sanders

By: Ashton Sanders

.htaccess 301 Redirect: Moved Permanently

Mar 16 2007

Filed under: htaccess

I’ve already discussed how to create a 301 permanent redirect using PHP that allows you to forward one page to another. But what if you you have an entire site to redirect? What if you’ve changed domain names? There has got to be a better way to redirect your site besides, adding a php 301 redirect to every page. Well there is! It’s called .htaccess.

My next post will be a quick introduction to “.htaccess”.

If you only want to redirect from one page on your site to another, this is the .htaccess code to use:

redirect 301 /oldfolder/oldfile.htm http://www.websitesinaflash.com/new.htm

There are three parts to this redirect (make sure you put 1 space in between each element):

1) “redirect 301”: This declares that you are doing a redirect, and that the code is 301: Permanent Redirect.

2) “/oldfolder/oldfile.htm”: This declares the page you want to redirect from.

3) “http://www.websitesinaflash.com/new.htm”: This is where you want the page to redirect them to.

This is useful when you have renamed pages, and want to make sure google knows where your new pages are, and also any visitors that would be directed to that old page will automatically be directed to the new page.

But what about directing an entire folder or site to another folder or site?
You’ll have to wait for next post. =]

Enjoy
Ashton

« Newer Posts
RSS

Where Am I?

You have found the semi-coherent ramblings of Ashton Sanders: a website designer, developer and webmaster. This is primarily Ashton's place to save notes about techniques and things that he learns in his never-ending conquest of the internet. Hopefully it's coherent enough to be useful to you too.

Subscribe:

Enter your email to get automatic emails whenever Ashton posts on the blog.

Email:

Advertisers:

Email Marketing $19/Month! OIOpublisher Learn how to make Money from Blogging Hillarious, High-Quality Shirts for $6/each Great Book Keeping and Invoicing Software Advertiser Here

Tags and Categories

Links

Blog Roll