Redirecting your website to a new domain

Have you ever needed to move your website to a new domain? This can be a tricky thing to do without breaking all the links to your website that exist in emails, print media, Facebook, or anywhere else on the internet. It is possible to redirect all incoming links with a piece of .htaccess code that will keep all your old links working.

.htaccess Code


RewriteEngine On
RewriteBase /

# New code to redirect from olddomain.com to newdomain.com
# Permanent redirect for caching purposes, also include the query string
RewriteCond %{HTTP_HOST} ^olddomain.com
RewriteRule (.*) http://newdomain.com/$1 [R=permanent,QSA,L]

# New code to redirect from www.olddomain.com to www.newdomain.com
RewriteCond %{HTTP_HOST} ^www.olddomain.com
RewriteRule (.*) http://www.newdomain.com/$1 [R=permanent,QSA,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
              

Note:
Replace olddomain.com with your old domain name, and newdomain.com with your new domain name. This will redirect all links that go to your old domain to your new domain.

Link Examples
http://blocksagencies.ca/insurance-tips/faq/
Takes you too
http://blocksagencies.ca/insurance-tips/faq/

http://blocksagencies.ca/contact-us/
Takes you too
http://blocksagencies.ca/contact-us/

Limiting the number of post/page revisions that are saved in WordPress

Whenever you modify a post or page on your WordPress site, a copy of is saved to make it possible to revert any changes that have been made.  Although this is a great feature when you quickly need to revert site content, the number of revisions can quickly add up and begin to take up a large amount of space in your database.  It is possible to set a maximum number of revisions that will be saved for each post/page by adding the following snippet to wp-config.php

Examples:

/* keep a maximum of 5 revisions for each post/page */
define('WP_POST_REVISIONS', 5);
/* disable revisions for post/pages */
define('WP_POST_REVISIONS', 9);

Empty WordPress trash automatically

Ever since the release of version 2.9 WordPress automatically deletes posts, pages, attachments, and comments, from the trash bin every 30 days. You are able to change this default behaviour by adding a snippet of code to the wp-config.php file of your WordPress install. This can be handy if you want to empty the trash more often to save space, or if you want to disable the trash altogether.

The following snippet would empty the trash every 7 days. You can set this to whatever number works best for you or even 0 to disable the trash feature completely.

Example:

define('EMPTY_TRASH_DAYS', 7 );

Speed up your website with Zlib

Having your website load as quickly as possible is crucial to make sure that you don’t scare your visitors away and recently even search engines are starting to rank your site based on its load time.

One way in which you can decrease the load time on your website is to enable zlib or gzip on your server.

If you have access to your php.ini you can enable zlib for all the pages/sites running on your server by changing the following values in your php.ini file to look like this:
[Read more…]

Launch of New Gossen Insurance Website

We are happy to announce the launch of a new website for Gossen Insurance.

Gossen Insurance is a Waldheim based insurance broker that offers competitive insurance options and a wide range of services for the local community.

They needed a new site for their business, and they needed it quickly. This website was setup and ready for use in a matter of a few weeks. It uses dynamic forms not only to allow visitors to the site to contact staff but also to request quotes for various types of insurance. The site is setup to be as simple and easy to use as possible, to allow site visitors to quickly access the information they need, and to easily be able to contact staff at the office if they need anything futher. We’ve also developed a section of the site for the staff to quickly and easily list rental property available in Waldheim as a public service to the community.

Using Trickle to Control Bandwidth Use in Any Program

There are a number of reasons why you would want to control how much bandwidth any given program is able to use. This can be done in a couple different ways, including options right with in the software, or through a software or hardware firewall. A great little program for managing bandwidth use is Trickle. Trickle runs completely in userspace, which means we don’t need to mess with a firewall, or even need root access.

If you’re on Ubuntu/Debian you should be able to install Trickle using

sudo apt-get install trickle

Now that you’ve got Trickle installed just use it before any network command to limit its bandwidth. Quite self-explanatory -u specifies upload and -d download.

trickle -u 25 -d 100 myCommand

The reason I first started using Trickle was so I could use Rsync and SCP to copy/backup files on my computer without negatively affecting the speed of my Internet connection. I have a fairly limited upload speed and this is an example of how I would limit the upload speed to 100 KB/s when backup up a folder with Rsync. Please note that when using Trickle with Rsync you have to use the -e option.

trickle -a -e "trickle -u 100 ssh" myFiles matthew@example.com:/home/matthew/backups/

It is even easier using Trickle with SCP where all you would need to do is use:

trickle -u 100 scp myFile.zip matthew@example.com:/home/matthew/backups/

Simplifying Managing Your SSH Connections by Using an SSH Config File

I’ve been using Linux as my primary operating system for over five years, and spent a good deal of time with it before that time. It’s only been within the last year or so that I’ve really begun to explore and enjoy working from the Linux/Unix command line. It’s greatly simplified my work flow when it comes to many tasks, and it seems I spend the majority of my time either in a command line or web browser now a days. Now that nearly 100% of the time when I’m working on a remote system, whether it is a server, Linux/Unix PC, or networking equipment, I’m usually connecting with SSH.

SSH is an incredibly powerful tool that can be used for everything from remote terminal access, to running entire graphical programs over a network. For me though remembering and having to type in all the IP Addresses, DNS Names, usernames and port numbers for all the SSH connections I use daily can be a real pain. That’s why setting up your own SSH config file can save huge amounts of time and effort in your day-to-day work.

This tutorial will be much easier to follow if you have a basic understanding of how to use SSH.
The steps in this tutorial were performed on Ubuntu 11.10. You may need to modify some steps depending on what system you are running.

GUI Version

1. Open Gedit (or your editor of your choice)
2. Click File->Save
Go to your home folder, and display hidden files by hitting CTRL+H on your keyboard.
Open the .ssh folder and save your new file as config

Command Line Version

1. First open up the terminal on your Linux/Unix based system.
2. Use vi (or any editor of your choice)

vi ~/.ssh/config

3. There are many options that you can set in a config file, but we will go over the settings that I usually use. Here’s an example:

Host myServer

HostName example.com
User root
Port 222


Host myDesktop

Hostname 192.168.1.100

This example shows two different SSH connections and their different options. The first is an example server that we want to connect to at example.com, with the username root, and where the SSH service is running on the non-standard port 222. The second is an example of a computer on your local network. As you can see we used a local IP address instead of a DNS name, also we didn’t bother setting a port number since it is running on the standard port 22. Also because in this example I’m assuming your connecting from another computer you own at the location there is no username set since I’m assuming you are using the same username on both computers you’re using for the connection.

4. Other options that I often use would be ServerAliveInterval, and ServerAliveCountMax.

Host myServer

HostName example.com
User root
Port 222
ServerAliveInterval 30
ServerAliveCountMax 120

Host myDesktop

Hostname 192.168.1.100
ServerAliveInterval 30
ServerAliveCountMax 120

This example would keep your SSH connection live for an hour by refreshing the connection every 30 seconds. This can be handy if you don’t want to be logged out every time you step away from your keyboard.

With your new SSH Config file instead of having to type in:

ssh -p 222 root@example.com 

You can just use:

ssh myServer

Hope this little trick saves you as much time as it has saved me.

Fix VIM in Ubuntu

An issue that I’ve noticed over the last couple releases of Ubuntu is that the “tiny” version of VIM is installed by default. This for me has always been a big issue, as a number of the controls in the regular VIM don’t work in the “tiny” version. Luckily for us though, this is a very easy and quick fix.
Just install the vim-gtk package using apt-get.

sudo apt-get install vim-gtk

You’ll now have the full version of VIM, as well as the GUI version.

Use Custom Footer Across Multiple Genesis Themes in WordPress MultiSite

This post is cross-posted from http://matthewsiemens.com

I’ve recently helped launch a number of projects that use WordPress MultiSite heavily, including MennoSites.ca and OurTownSite.ca. This post outlines how to quickly and easily setup a simple WordPress plugin to let you add the same custom footer to every Genesis Theme in your WordPress MultiSite install.

I’ve used a number of Theme suppliers working with WordPress over the years. Lately I’ve begun using Themes based on the Genesis Framework almost exclusively. When I started working with Genesis I took a look around to see what was the best way to change the Theme footer and include my own content.
I found this code snippet on the StudioPress site that does exactly what I wanted.

I found this code snippet on the StudioPress site that does exactly what I wanted.

/** Customize the credits */
add_filter('genesis_footer_creds_text', 'custom_footer_creds_text');
function custom_footer_creds_text($creds) {
    $creds = 'Copyright &copy; &middot; <a href="http://mydomain.com">My Custom Link</a> &middot; Built on the Genesis Framework';
    return $creds;
}

If you copy and paste this code into your Child Themes function file, you can quickly and easily modify the Themes footer.

I wanted to make a few changes to customize the footer for MennoSites.ca. I wanted to display a copyright notice for the current website, a link to the main MennoSites.ca site and a link to the WordPress Administration area for the current site. I used the PHP date function to display the current year for the copyright notice. Than I used the WordPress site_url() function and the WordPress variable $blog_title together create a link to with the name of the current site and its address for the copyright notice. After that I simply hard-coded a link to MennoSites. Finally I used the WordPress site_url() function one last time to create a link to the current sites WordPress Administration Section.
You can see the code snippet I’m using below.

/** Customize the credits */
add_filter('genesis_footer_creds_text', 'custom_footer_creds_text');
function custom_footer_creds_text($creds) {
    $blog_title = get_bloginfo();
    $creds = 'Copyright © '.date(Y).' &middot; <a href="'.site_url().'">'.$blog_title.'</a> &middot; Part of the <a href="http://mennosites.ca" title="MennoSites.ca Network">MennoSites.ca Network</a> &middot; <a href="'.site_url().'/wp-admin/" title="Website Admin">Website Admin</a>';
    return $creds;
}

This snippet is in use on MennoSites.ca and you can actually see it being used at the bottom of this page. Using date(Y),.site_url,$blog_title means that our copyright information is always up to date, and that this snippet will work on any WordPress Site using a Genesis Theme without any other modifications. The snippet will always display the correct links for whatever site it is added too.

On MennoSites.ca we have dozens of Genesis Themes available, instead of adding this snippet to the functions.php file of every theme I wanted to have one location where I could add this snippet and modify it in the future. Using the extensible power of WordPress I created a simple plugin to do exactly that.

To do the same thing, just create a file called easy-genesis-footer.php and open it with your favourite editor. Now add the following code to your file.

<?php
/* Plugin Name: MennoSites.ca Easy Genesis Footer Plugin
URI: http://mennosites.ca
Description: Manage The Footer For Your Genesis Themes All In One Place.
Version: 1.0
Author: Matthew Siemens
Author URI: http://matthewsiemens.com
License: GPL2 */
?>

Now just add the code snippet from above so that your file looks like this.

<?php
Plugin Name: MennoSites.ca Easy Genesis Footer
Plugin URI: http://mennosites.ca
Description: Manage The Footer For Your Genesis Themes All In One Place.
Version: 1.0
Author: Matthew Siemens
Author URI: http://matthewsiemens.com
License: GPL2
*/

/** Customize the credits */
add_filter('genesis_footer_creds_text', 'custom_footer_creds_text');
function custom_footer_creds_text($creds) {
    $blog_title = get_bloginfo();
    $creds = 'Copyright © '.date(Y).' &middot; <a href="'.site_url().'">'.$blog_title.'</a> &middot; Part of the <a href="http://mennosites.ca" title="MennoSites.ca Network">MennoSites.ca Network</a> &middot; <a href="'.site_url().'/wp-admin/" title="Website Admin">Website Admin</a>';
    return $creds;
}
?>

Just remove the link to MennoSites.ca and replace it with a link to your own website. On your web host create a folder called mu-plugins inside wp-content if one doesn’t already exist and upload the file you created to it. This will force the plugin to be enabled across your WordPress MultiSite network, and will update and display your new footer automatically. Please only use this plugin if you are only using Genesis Themes on your MultiSite setup, or you might run into some issues.

I hope this information was helpful, I know it’s saved me from modifying dozens of functions.php files every time I want to make a change to the footer.