php のheader関数でリダイレクトするとステータスコードは302
.となることをこのたび初めて知った。
PHP: header – Manual
なので301 を返したい場合は以下のようにすればよいとのこと。
header("HTTP/1.0 301 Moved Permanently"); header("Location: http://www.oganosin.net/xxxxx/");
覚えておこう。
となることをこのたび初めて知った。
PHP: header – Manual
なので301 を返したい場合は以下のようにすればよいとのこと。
header("HTTP/1.0 301 Moved Permanently"); header("Location: http://www.oganosin.net/xxxxx/");
覚えておこう。
Powered by Twitter Tools.
はい、どん!
シンプル・イズ・ベストやね。
でもテーマを当てる際に問題があったのでメモ。このブログはさくらインターネットのサーバーなのですが
P2テーマをあてようとするとエラーが発生・・・。またかよさくらインターネット、と思いいろいろググる。
はい答えはhttp://wordpress.org/support/topic/255088に!
なんとfunction.php とentry.phpにショートオープンタグで書かれている部分があり、ショートオープンタグがoffになっているサーバーでエラーが起こっていただけでした。
上記フォーラムから該当部分を引用しておきます。次のリリースでは修正されていることでしょう。
* line 429 of functions.php
<div class="postcontent<?php if (current_user_can( ‘edit_post’, get_the_id() )) {?> editarea<?}?>"….should be:
<div class="postcontent<?php if (current_user_can( ‘edit_post’, get_the_id() )) {?> editarea<?php } ?>"* line 27 of entry.php
<div class="postcontent<?php if (current_user_can( ‘edit_post’, get_the_id() )) {?> editarea<?}?>"…
shoud be:
`<div class="postcontent<?php if (current_user_can( ‘edit_post’, get_the_id() )) {?> editarea<?php } ?>"
追記:2009/4/29
結局テーマ戻しました。
今回はブログのデータ以降をxml-rpc経由でやってみようというサンプル。
wordpressだとDBをまるまる移すのが定番みたいだけど天の邪鬼にperl + xml-rpcでやってみました。
例によって公開できる部分だけ抜き出しているので、このソースはあくまでも雛型です。
ポイント
前回と同じく重複チェックには穴があるので要注意。
#!/usr/bin/perl use strict; use warnings; use Encode; use LWP::UserAgent; use HTTP::Request; use XML::LibXML; use XMLRPC::Lite; #use XMLRPC::Lite trace => 'debug' ; use Data::Dumper; use File::Basename; use MIME::Base64; use MIME::Parser; use Getopt::Std; use vars qw(%interface $username $passwd $target $postcnt); BEGIN { $interface{'from'} = 'http://www.example.com/blog/xmlrpc.php'; $interface{'to'} = 'http://www.example.net/blog/xmlrpc.php'; $username = 'xxxxxx'; $passwd ='xxxxxx'; $target = ''; $postcnt = 100; } # get original data my $rpc = XMLRPC::Lite->new(); $rpc->proxy($interface{'from'}); my $res = $rpc->call("metaWeblog.getRecentPosts", 1, # blog ID $username, $passwd, $postcnt, )->result; $rpc->proxy($interface{'to'}); foreach my $content (@{$res}) { # get posts #print Dumper $content; my ($title, $description, $date, $excerpt, $wp_slug, $keyword); $title = $content->{'title'}; $description = $content->{'description'}; $date = $content->{'dateCreated'}; $excerpt = $content->{'excerpt'}; $wp_slug = $content->{'wp_slug'}; $keyword = $content->{'mt_keywords'}; # check data $target = "http://www.example.net/blog/uncategorized/" . $wp_slug . "/"; my $ua = new LWP::UserAgent; my $req = new HTTP::Request(HEAD => $target); my $resp = $ua->request($req); if($resp->{'_rc'} eq '200'){ print STDERR "Alredy convert URL: $target\n"; next; } # edit posts # get category_id $res = $rpc->call("wp.suggestCategories", 1, $username, $passwd, Encode::encode('utf8', $content->{'categories'}[0]), )->result; my $category_id = $res->[0]{'category_id'}; $res = $rpc->call("metaWeblog.newPost", 1, # blog ID $username, $passwd, { 'title' => Encode::encode('utf8', "$title"), 'description' => Encode::encode('utf8', "$description"), 'dateCreated' => Encode::encode('utf8', "$date"), 'mt_excerpt' => Encode::encode('utf8', "$excerpt"), 'mt_keywords' => Encode::encode('utf8', "$keyword"), 'wp_slug' => Encode::encode('utf8', "$wp_slug"), #'custom_fields'=> [ # { # 'key' => '', # 'value' => '', # }, #], }, 1 )->result; my $postid = $res; $res = $rpc->call("mt.setPostCategories", $postid, $username, $passwd, [ { "categoryId" => $category_id, "isPrimary" => 1 } ] )-> result; } exit 1;
これはドコモから。
以下絵文字
写真も添付します