In Search of Optimization

A Mike Lopez Search Engine Optimization Blog
Our Home Subscribe to our Feed

What is a 301 Redirect?

A 301 redirect is a method of telling web browsers and search engines that a web page or site has been permanently moved to a new location. Web browsers will usually follow 301 redirects without the need for user action.

When should a 301 Redirect be used?

A 301 redirect should be used whenever a website is moved to a new domain name or whenever a webpage has been renamed or relocated so that search engines will quickly update their database and thus preserve the search engine rankings of the site or page.

How do I issue a 301 Redirect?

It’s pretty simple really

First, edit your website’s .htaccess file. If you don’t have an .htaccess file yet, just create a new one. Note the filename it’s “.htaccess” with the dot included.

Next, add the following code at the bottom of your .htaccess file:

redirect 301 someoldpage.html somenewpage.html

Simple, right? I told you. Here’s a simple explanation of what we just did:

redirect 301 - the instruction that the site or page has permanently moved

someoldpage.html - the old webpage

somenewpage.html - the new webpage

All you need to change here are someoldpage.html and somenewpage.html

To redirect an entire site to a new domain
redirect 301 / http://www.newdomain.com/

To redirect an entire folder to a different folder
redirect 301 /someoldfolder /somenewfolder

To redirect some file from on your old domain to some file on a different domain
redirect 301 /some/old/file.html http://www.newdomain.com/file.html

Need more examples and detail?  Visit the Guide to Applying 301 Redirects in Apache.

There ya go! Enjoy!


I submitted a total of 8 sites to Google sitemaps.  If you’re familiar with Google sitemaps, it will require you to put a certain file on a certain location of your site to verify your ownership of the site.  This is done for privacy reasons.  In my case, Google asked me to put a file named ‘google0eb4543125f834aa.html‘ on all of my sites’ root web folder.  I did so, and pressed the Verify button but I got an error telling me that the file can’t be found.

I tried and tried and tried but still to no avail.  I slept for a while, and when I woke up, I gave it a try again but still to no avail.  It was then that I decided to check my access logs in the hope to find out why Google can’t find the file.

When I checked my access logs, I realized that the problem was not on my end.  It was Google’s :D.  Instead of accessing ‘google0eb4543125f834aa.html’, it was looking for ‘googleeb4543125f834aa.html’ instead.  See the subtle difference?  No zero (’0′) after  ‘google’.  So I renamed all Google verification files to match what was on my access logs and retried the verification process!  Like magic, it worked!!!

I know this is a Google bug and I know they will fix this if they were notified so I went to the Google Sitemaps discussion forum to post it but guess what, some other user alraedy found out about it and posted it there.  The post is named “Error in Google Verification - Dropping leading zeros“.  Nonetheless, I decided to add to the same post so as to confirm the bug. :D

Now all my sites are verified!  I know Google would have fixed this if I just waited but I just can’t wait…

Ciao!


If you are a Wordpress user and are conscious about your Search Engine Ranking, then like me, you might have already installed two of the most useful Wordpress plugins that has to do with Search Engine Optimization namely, the Google Sitemaps Plugin and the Subdomain Plugin. If so, good for you.

There is one problem with installing both plugins though. Take a look at this:


http://www.mikelopez.info/
2006-02-28T12:31:01+00:00
daily
1



http://science-and-technology.mikelopez.info/2006/02/27/comet-pojmanski-by-eric-africa/
2006-02-28T12:31:01+00:00
weekly
0.1



http://articles.mikelopez.info/2006/02/27/miscommunication/
2006-02-27T19:39:48+00:00
weekly
0.1

The above sitemap entries were taken from the sitemap.xml file generated by the Google Sitemaps plugin in Wordpress. At first glance, there appears to be no problem with the above sitemap entries until you submit them to Google.

One rule with Google sitemaps is that sitemap entries should be located under the same domain name. Google however treats subdomains as different domain names. This means that Google will complain about certain entries in your sitemap that doesn’t belong to the same domain name.

Some may say that it’s OK. Just submit the same sitemap file for each subdomain and ignore the errors. Though this may work, I decided to be a bit cautious and gave google what it wants - an error free sitemap file.

So, what did I do? I wrote a script. To demonstrate how the script works, simply check the following links (each link will open in a separate window and may take some time to load).

As you can see, the above links provide sitemap files that have been ‘cleaned’ - meaning, not containing entries from different domain names / subdomain names. Furthermore, the above sitemap files are generated on the fly by reading the sitemap.xml generated by the Google Sitemaps plugin and ‘cleaning’ it so that it returns only entries matching the subdomain that was used to access the sitemap.xml.php file.

Now, you can submit each sitemap file for each subdomain and see no more entry but instead of submitting sitemap.xml or sitemap.xml.gz, you will now be submitting sitemap.xml.php. This time, Google will no longer complain :D

Want to do the same on your Wordpress site? If so, just download the file below:

sitemap_cleaner.zip - 713 bytes

Here’s how to use it.

  1. Unzip the file
  2. Edit sitemap.xml.php and change the line that says:
    $map = str_replace (”http://www.mikelopez.info/”, “http://” . $host . “/”, $map);
    - to -
    $map = str_replace (”http://www.yourdomain.com/”, “http://” . $host . “/”, $map);
  3. Upload the file to your Wordpress web folder
  4. Give it a try by accessing www.yourdomain.com/sitemap.xml.php and sub.yourdomain.com/sitemap.xml.php.

One last note, this only works as expected on subdomains that are created by the Wordpress Subdomain Plugin and on the sitemap.xml file generated by the Google Sitemap plugin for Wordpress.

If you have questions, comments, suggestions, just post them below.

Ciao!



In Search of Optimization · Template by Mike Lopez

Good luck to The Busby SEO Challenge