Archive

Archive for March, 2010

Response.Redirect and 302 and 301 status codes

March 8th, 2010 No comments

If you use Response.Redirect to direct users to a new location, you should be aware that it issues a status code of 302, which means that “the resource resides temporarily under a different URI.” If you intend to communicate that the resource has permanently changed locations, you should not use Response.Redirect. This is important for search engines and other crawlers that might need to know the definitive url.

To send a 301 redirect:

Response.Status = "301 Moved Permanently";
Response.StatusCode = 301;
Response.AddHeader("Location", url);
Response.End();

Update: ASP.Net 4.0 ads a Response.RedirectPermanent() method.

Categories: code Tags:

Set the admin color scheme for all WordPress users

March 6th, 2010 No comments
INSERT INTO wp_usermeta
(
user_id,
meta_key,
meta_value
)
(
SELECT
id,
'admin_color',
'classic'
FROM wp_users
WHERE id  NOT  IN (SELECT user_Id FROM wp_usermeta WHERE meta_key = 'admin_color')
)
 
UPDATE wp_usermeta SET meta_value = 'classic' WHERE meta_key = 'admin_color'

Categories: code Tags: ,

Bulk update post slugs in a WordPress blog

March 6th, 2010 2 comments

The following PHP script updates missing post slugs (permalinks) in a WordPress blogs, or reformats them according to your needs:
Continue reading “Bulk update post slugs in a WordPress blog” »

Categories: code Tags: , ,

Delete smart quotes and fix latin1>utf8 encoding issues in WordPress

March 4th, 2010 No comments

If you use wptexturize, smart quotes will mess you up. This is a quick and dirty fix.
Continue reading “Delete smart quotes and fix latin1>utf8 encoding issues in WordPress” »

Categories: code Tags:

SQL script to migrate from Movable Type to WordPress

March 2nd, 2010 5 comments

While trying to migrate a large blog from Movable Type to WordPress, I found the built-in export and import functionality unable to handle volume of content on the blog or to properly preserve the primary keys needed for permalinks.

With assistance from Alvaro on the MisesDev list, we came up with the following MySql SQL script to import the entries directly from the Movable Type (5.01) database to WordPress (2.9.2). What would take many hours otherwise can be done in a minute or two. This is especially important if you don’t want to lose data during the time it takes to migrate the blog, as the script can be run immediately before the switch. This script also includes additional stuff like IP addresses and url-friendly names.
Continue reading “SQL script to migrate from Movable Type to WordPress” »

Categories: code Tags: , ,