Brian Nettles
It's my blog and I share.


 

Archive for May, 2008

How to Redirect a Website to Remove the ‘www’

Friday, May 30th, 2008

Several months ago, I read in a blog where Matt Cutts spoke at a Wordpress Bootcamp. He specifically said that with Google, a website with www and the same website without the www are treated as two separate websites.  What I take from this is that if you trying to maximize your search engine results, it is better if you either stick with one or the other for your incoming links.

So the question comes up when using Apache as your webserver, how can you take your new website and redirect the www to the base url name.  In my example, I wanted http://www.wilderness-gear.com to redirect to http://wilderness-gear.com.  The answer is simple, use the .htaccess file.

Go to your base directory and check if you have a hidden file called .htaccess.  If you have one, then back it up immediately.  Your web application may be using it.  Wordpress does.  My example here is for a website that did not have an .htaccess file in the base directory.  So all I did was create the .htaccess file in the base directory and add the following:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.wilderness-gear\.com$ [NC]
RewriteRule ^(.*)$ http://wilderness-gear.com%{REQUEST_URI} [R=301,L]
</IfModule>

All done.  Now the http://www.wilderness-gear.com redirects to http://wilderness-gear.com.

mysqldump: Got error: 1146: Table ‘databasename.tablename’ doesn’t exist when doing LOCK TABLES

Monday, May 26th, 2008

Ran into this error tonight while copying tables from one database into another. 

I was using the mysqldump command as follows:

mysqldump -h localhost -u username -p --add-drop-table wildernessgear  wp_31_term_relationship /home/bnettles/wp_31_term_relationship.sql

This command was supposed to export just the one table wp_31_term_relationship.  I had already exported the 30 previous tables in the database.  All of a sudden this one was causing a problem with the following error message.

mysqldump: Got error: 1146: Table ‘wildernessgear.wp_31_term_relationship ‘ doesn’t exist when doing LOCK TABLES.

I searched the internet for a while and wasted a half an hour not being able to figure out how to unlock the tables.  Then I discovered the real problem.  The table did not exist.  There was a typo.  It was supposed to be wp_31_term_relationships with an “s” at the end, not wp_31_term_relationship.

Looks like Mysql is using the wrong error message in this case.


Blog Information Profile for Supertramp678