Redirecting Traffic to New Website
Simple Method to Use With Apache
To set up 301 redirects for an entire "domain" the simplest solution for us was to make changes in our Apache configuration file. We do our own hosting, but if your primary hosting is on a VPS or even on some shared hosting setups, you can get access to your httpd.conf file to edit it, and this solution should work for you as well. I'm going to give you a short step-by-step description of the process, and then put up a brief screen-capture video of the work as well.
The changes you need to make are all in the VirtualHosts records in your configuration files. These techniques should work for both Apache 1.3 and Apache 2.X; the only difference might be which files the configurations are stored in. In most Apache 1.3 setups, they will be in the main httpd.conf file; in Apache 2.X setups, generally there will be a main httpd.conf file, but the virtual hosts will be set up in a separate file named httpd-vhosts.conf, which will be stored in the "extra" subdirectory under apache/conf. Assuming the domain you want to redirect is named "olddomain.com" and the one you want to redirect to is "newdomain.com", here are the edits to make:
- Remove any ServerAlias record for the "old" domain from the record for the "new" domain
- Add a VirtualHosts record for the "old" domain that contains the text shown below
- Restart Apache
Redirect permanent / http://www.newdomain.com/
A few extra comments here: first, the IP address is just a standin; obviously yours will be different. Second, the extra ServerAlias entry is just to catch any oddballs that might try to access the site without the "www". Third, and this is crucial, do NOT forget the trailing "/" at the end of the newdomain URL. Once you restart the web server, any attempt to access any page under www.olddomain.com will be automatically redirected to the matching page under www.newdomain.com, using a "301" permanent-redirect. This is important because it will signal any search engines accessing the old URL that the new URL is in fact the same page it previously indexed at its new permanent address. This will prevent any loss in page ranking due to the move.
Video to Come!
More posts filed under category: Website Basics
Like this post? Subscribe to our RSS feed and get loads more!