In
a previous article, I outlined some tips that can save
your traffic and rankings when you rename or move around
a few files on your current website, or change domain
names - by implementing a .htaccess
301 redirect.
The basic 301 redirect works very well in that scenario,
where folder paths will remain the same, but what if
you are changing your domain name and/or changing many
folder names? Writing out dozens, hundreds or perhaps
even thousands of basic 301 redirects would be very
time consuming and the potential for errors is huge.
If you've been using your current domain name for several
years, you have probably built up a great deal of brand
awareness amongst your visitors, some solid search engine
rankings and other links pointing to your site. It would
be a shame to lose all that hard work - but there is
a fairly simple way and relatively safe option for a
smooth and seamless transition through the use of mod_rewrite
and a .htaccess file.
What is mod_rewrite?
mod_rewrite is an Apache module which allows for the
rewriting of URLs. This "redirection" is transparent
to the end-user and requires no special software on
the visitor's end. In the instance of changing your
domain name, when you use mod_rewrite; the visitor who
goes to your old domain will still see the old domain
name in their browser address bar on the first page
they visit, but will actually be viewing content under
the new name. Using the mod_rewrite strategy is also
very search engine friendly.
What is a .htaccess file?
When a visitor/spider requests a web page via any means,
your web server checks for a .htaccess file if your
hosting runs Apache - which is a very common web server.
The .htaccess file contains specific Apache directives
for certain requests, including security, redirection
issues and how to handle certain errors.
Before you do anything...
If you're also moving servers as well as the domain
name change; there's a variety of other issues you should
consider first.
Step 1 - check your web host
If you're not sure of the server software used by your
hosting service, you'll need to check with them to ensure
that they support the mod_rewrite module, otherwise
this will not work.
Step 2 - Activate your new domain name.
Once you know for sure your host supports mod_rewrite;
upload all your files to the account for the new domain
name. Ensure that the file base structure and naming
is exactly the same as it was under the old domain name.
Step 3 - create a .htaccess file
Creating a .htacess file can be done with a simple text
editor such as Notepad. Ensure when you name the file
that you precede htaccess with "." at the beginning
of the file name. This file has no tail extension, the
name should be just: .htaccess
Step 4 - insert the syntax
Basic - domain name change
For a basic domain name change, where folder names haven't
changed, simply copy these following lines into the
file, replacing "new.com" with the new domain name.
If you have an existing .htaccess file; keep a backup
copy of it and then remove all other instructions from
the file; except for these:
RewriteEngine On
RewriteRule ^(.*)$ http://www.new.com/$1 [R=301,L]
The Rewrite rule in this instance simply re-maps from
old domain to new. Be aware that the old domain name
will still appear in the browser window. To check to
make sure you are viewing the content on the new domain,
simply right-click over an image and select "properties"
to view the path.
Advanced - domain name/folder change
If you are changing folder names, then the following
lines should be used. The RewriteRule section of the
following statement should be on a single line and you'll
need a RewriteRule line for each folder change. There's
no need to use the "RewriteEngine On" again if you have
also used the basic RewriteRule in your .htaccess file.
RewriteEngine On
RewriteRule ^olddir/(.*)$ http://new.com/newdir/$1 [R=301,L]
Save the file, upload it back into your web (old domain)
in the root document directory. Test it out by typing
in the old domain name. You should be instantly and
seamlessly transported to the new domain; even if you
have typed in a particular page address on the old domain
you should see exactly the same page under the new domain.
Effects on search engine spiders
The mod_rewrite strategy is probably the safest way
to preserve your rankings. On the next spidering, the
search engine spider won't actually read the .htaccess
file, it's the server that generates the response based
on the contents of .htaccess. The search engine spider
recognizes the response from the server as valid. The
"301" in the syntax means "moved permanently".
In the next update, the old domain name should disappear
and be replaced with the new one; but be aware this
*could* take up to a couple of months - your current
domain name may still show in listings; but anyone who
clicks from the listing will still go to the new domain.
If you do see some fluctuations in rankings initially
during the transition, don't panic - this is pretty
normal while backlinks are recalculated etc. - you could
have a few nail-biting weeks. Also bear in mind that
search engines operate according to their own rules
and can change those rules and methods of operation
at any time. Any change to your pages or lack thereof
can have undesired effects. The mod_rewrite strategy
is a case of "if you have to do it, this is the best
way to go".
It is very important though that you get your link partners
to update their links to you if you will be deactivating
the old domain name in the future. Once the domain name
is de-activated, and therefore the .htaccess file, all
the links from other sites will be useless and *that*
could impact on your future rankings.
More on mod_rewrite
mod_rewrite is a very powerful tool; the above application
is just one example of what you can achieve. For further
documentation on mod_rewrite:
http://httpd.apache.org/docs/mod/mod_rewrite.html
About
The Author: SEO Consultant
- Offers search engine optimization, link popularity
building and search engine friendly website design services.
|