Archive for May 12th, 2010
Copy a Table into another
by z3n on May.12, 2010, under Tips & Hints
Problem:
How to copy a table into another, like a fast backup of a single table.
Solution:
MySQL:
create table <destination> select * from <source>
MSSQL:
select * into <destination> From <source>
Notes:
Although primary keys are preserved, the primary key column will not be automatically set on the destination table, so watch out before start inserting content on the destination.
.htaccess to redirect non www to www
by z3n on May.12, 2010, under Tips & Hints
Since i keep forgetting this i’m posting here:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^(www\.|$) [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
This kind of redirect helps spiders knowing where you site really is, usually if you don’t have those and your non www domain is the same of your www you may get penalized for having a duplicate site. With this 301 redirect this will not happen.