竹枝

Tag: wordpress

修复因改变wordpress固定链接而导致的404错误

by anyshpm on Feb.09, 2010, under 旅程

前两天把我博客的固定链接从
http://blog.anyshpm.com/archives/%postid%
改成了
http://blog.anyshpm.com/%year%/%monthnum%/%day%/%postname%.html
结果原来的链接地址全变成了404,真悲剧,得想办法解决。

本来想着wordpress应该兼容各种固定链接的形式,没想到不行,也有可能是主题的问题。我没那个功夫去看代码,就想到用apache的rewrite。

可惜我对.htaccess文件的语法基本一无所知,正则表达式也是一样不懂,貌似也没人遇到过这种问题。

于是乎,我看了资料无数,试了不下百次,终于憋出几条语句
RewriteCond %{HTTP_HOST} ^blog.anyshpm.com [NC]
RewriteRule archives/date/(.*) http://blog.anyshpm.com/$1 [L,R=301]
RewriteRule archives/tag/(.*) http://blog.anyshpm.com/tag/$1 [L,R=301]
RewriteRule archives/(.*) http://blog.anyshpm.com/?p=$1 [L,R=301]

加上原先的几条,最终写成这样
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteCond %{HTTP_HOST} ^blog.anyshpm.com [NC]
RewriteRule archives/date/(.*) http://blog.anyshpm.com/$1 [L,R=301]
RewriteRule archives/tag/(.*) http://blog.anyshpm.com/tag/$1 [L,R=301]
RewriteRule archives/(.*) http://blog.anyshpm.com/?p=$1 [L,R=301]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

问题就解决了。里面用了301跳转,把原来的
http://blog.anyshpm.com/archives/%postid%
转到
http://blog.anyshpm.com/?p=%postid%
然后wordpress会在跳转一次,变成默认的固定链接形式。
archives/date/和archives/tag/也一样做相应的处理。

Leave a Comment :, , , , more...

让Twitter tools用上Twitter API proxy

by anyshpm on Feb.05, 2010, under 旅程

博客放在国内,怎么让wordpress访问twitter呢?

使用Twitter API proxy就可以了。

让博客通过Twitter API proxy访问twitter。

wordpress的插件很丰富,肯定有一个适合的Twitter插件。

看上了Twitter tools,可貌似它不支持Twitter API proxy。

怎么办呢?

自己动手,丰衣足食啊。

找到twitter-tools.php文件中的:

1
2
3
4
5
6
define('AKTT_API_POST_STATUS', 'http://twitter.com/statuses/update.json');
define('AKTT_API_USER_TIMELINE', 'http://twitter.com/statuses/user_timeline.json');
define('AKTT_API_STATUS_SHOW', 'http://twitter.com/statuses/show/###ID###.json');
define('AKTT_PROFILE_URL', 'http://twitter.com/###USERNAME###'); 
define('AKTT_STATUS_URL', 'http://twitter.com/###USERNAME###/statuses/###STATUS###'); 
define('AKTT_HASHTAG_URL', 'http://search.twitter.com/search?q=###HASHTAG###');

用Twitter API proxy地址替换twitter.com即可。

我在GAE上搭建的Twitter API proxy可供大家免费无偿使用。

1
2
3
4
5
6
define('AKTT_API_POST_STATUS', 'http://anytwitter.appspot.com/api/statuses/update.json');
define('AKTT_API_USER_TIMELINE', 'http://anytwitter.appspot.com/api/statuses/user_timeline.json');
define('AKTT_API_STATUS_SHOW', 'http://anytwitter.appspot.com/api/statuses/show/###ID###.json');
define('AKTT_PROFILE_URL', 'http://anytwitter.appspot.com/api/###USERNAME###'); 
define('AKTT_STATUS_URL', 'http://anytwitter.appspot.com/api/###USERNAME###/statuses/###STATUS###');
define('AKTT_HASHTAG_URL', 'http://anytwitter.appspot.com/api/search?q=###HASHTAG###');
1 Comment :, , , , more...

开始使用自己翻译的主题

by anyshpm on Aug.08, 2009, under 旅程

看看页面底部的版权信息,已经改了,呵呵……

自己大概翻译了一下,有些地方还不知道该怎么翻译。

先自己用着,也算测试了。

有兴趣的可以到http://code.google.com/p/anypixel/查找源代码。

感谢sam

Leave a Comment :, , , more...

anyNote

by anyshpm on Jan.28, 2009, under 旅程

我的第一个wordpress插件,一个便笺插件,可以把日志的部分内容以便笺形式显示。

如:

?View Code ANYNOTE
1
2
我做了一个wordpress插件
名字叫anyNote

(continue reading…)

Leave a Comment :, , more...

audio player

by anyshpm on Aug.31, 2008, under 旅程

在wordpress里装了audio player插件,用来放音乐,放弃了音乐八宝盒的博客音乐组件。
我挺看好音乐八宝盒这个网站的,但总觉得这个网站好像无人看管似的,担心它不知哪天就挂了。
所以就决定用wordpress的audio player插件。

(continue reading…)

Leave a Comment :, , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...