FVN Tech Blog Coding or Programming in C#/PHP | Linux or Windows Server Backend | New Media | SNS | Misc …

4Mar/100

Upgraded to WP 2.9.2

and added WPtouch.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
8Feb/100

Upgraded to WP 2.9.1

nth new.

added a new plugin: light-social to "insert a set of social share links at the bottom of each post, focused on technical blogs."

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
20Jan/097

A Wordpress broken link helper

Just an example.
For wordpress ppl who changed their perm link.

  1. <?php
  2. require_once( dirname(__FILE__) . '/wp-load.php' );
  3.  
  4. global $wpdb;
  5.  
  6. $uri = $_SERVER["REQUEST_URI"];
  7. $pattern = "/^\/(\d{4})\/(\d{2})\/(\d{2})\/([^\d].*|\d+[.^-]*).html$/";
  8. if (preg_match($pattern, $uri, $match) == 1)
  9. {
  10.     $year = $match[1];
  11.     $month = $match[2];
  12.     $mday = $match[3];
  13.     $post_name = $match[4];
  14.  
  15.     if ((string)(int)$post_name == $post_name) {
  16.         $id = (int)$post_name;
  17.         $link = get_permalink($id);
  18.         if ($link)
  19.             wp_redirect($link, '301'); // Permanent redirect
  20.     }
  21.     $query = "SELECT post_id FROM $wpdb->postmeta, $wpdb->posts WHERE ID=post_id ".
  22.         "AND YEAR(post_date) = $year AND MONTH(post_date) = $month AND DAYOFMONTH(post_date) = $mday ".
  23.         "AND post_name = \"$post_name\" LIMIT 1";
  24.  
  25.     $id = (int)$wpdb->get_var($query);
  26.     $link = get_permalink($id);
  27.     if ($link) wp_redirect($link, '301'); // Permanent redirect
  28.  
  29.     $query = "SELECT ID FROM $wpdb->posts WHERE ".
  30.         "YEAR(post_date) = $year AND MONTH(post_date) = $month AND DAYOFMONTH(post_date) = $mday ".
  31.         "AND post_name = \"$post_name\" LIMIT 1";
  32.     $id = (int)$wpdb->get_var($query);
  33.     $link = get_permalink($id);
  34.         if ($link) wp_redirect($link, '301'); // Permanent redirect
  35.  
  36.     $link = "/$year/$month/$mday/";
  37.  
  38.     if (strstr($_SERVER["HTTP_USER_AGENT"], "Mozilla") === FALSE) // if it's not a user
  39.     {
  40.         wp_redirect($link, '302');
  41.     }
  42. ?>
  43. <html><head>
  44. <meta http-equiv="refresh" content="5;url=<?php echo $link;?>" / > <title>Page has moved</title> </head>
  45. <body><p>The permant link changes, however <i>broken link helper</i> can't solve it automaticlly, it will redirect you to <a href="<?php echo $link;?>">the date archive page</a>. It would be nice if you can report broken links to feuvan#feuvan.net.</p>
  46. </body></html>
  47. <?php } ?>

Corresponding nginx configuration block:

server {
listen 80;
server_name blog.feuvan.net;

root /home/feuvan/wwwdata/blog;
index index.php;
if (-e $request_filename) {
break;
}

rewrite ^/index.php/(.+)$ /index.php?q=$1 last;
rewrite "^/([0-9]{4})/([0-9]{2})/([0-9]{2})/([^\d].*|\d+[.^-]*).html" /brokenlinkhelper.php last;
#rewrite ^/(.+)$ /index.php?q=$1 last;
rewrite ^/ /index.php last;

location ~ \.php$ {
fastcgi_pass unix:/tmp/php.sock;
}
}

Hope it helps.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
Tagged as: , 7 Comments
20Apr/071

Lighttpd url-redirect for Wordpress Permlink changes

I changed my wordpress blog entry permlink format. But some link to my blog exists on Internet doesn't work which results in a HTTP 404 error.

Why redirect is better then rewrite

Someone may have the same question, but take it easy, it depends on your decision.

But rewrite has it's benefits also, existed link will work without any changes. RSS feed, your live writer(maybe you prefer Word2007? :P) will still work, no need to change the configuration.

I want all visitors include search engine spiders get to know that the permlink changes, that's why I choose redirect, not rewrite.

Draft conf, simple and ugly

For example, http://feuvan.net/wordpress/?p=107 now should be http://blog.feuvan.net/index.php/2007/03/10/win-ce-platform-builder-60-evalutation-offline-download.html, then I have to configure my lighttpd configure like these.

$HTTP["url"] =~ "^/wordpress" {
    url.redirect =(
        "^/wordpress/(.*)$" => "http://blog.feuvan.net/index.php/$1"
    )
}

But some links like http://feuvan.net/wordpress/index.php?p=56 will be redirected to http://blog.feuvan.net/index.php/index.php?p=56, it's ugly, er......

More clean conf file

So here we have a newer configure file:

$HTTP["url"] =~ "^/wordpress" {
    url.redirect =(
        "^/wordpress/index.php?(.*)$" => "http://blog.feuvan.net/index.php/$1",
        "^/wordpress/(.*)$" => "http://blog.feuvan.net/index.php/$1"
    )
}

Now the old link will be redirected to http://blog.feuvan.net/index.php/?p=56.

Furthermore

Wait, why not redirect to the new permlink directly?

Maybe I can throw out a solution.

NOTE:

You should enable mod_redirect to make the configuration works for you.

The article is specified to lighttpd 1.4.x series.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
5Mar/070

升级了wordpress

2.1.2

还不错

出了点小意外
搞定

wordpress plugin widget不错

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
Tagged as: No Comments

Pages

Recent Posts

Categories

Tags

apache baidu C# Debian dotNET economy gadget GMA Google hulu IE7 Intel jiwai lighttpd Linux Mobile mod_extforward mojiti nginx oscanner OVAL Parallel PHP phproxy politics proxy Python regsvr32 SNS squid subversion trac TV Vista Visual Studio Windows Live Windows Mobile WLM wordpress wow WTL wzdftpd XDebug XML Zend Framework

Archives

Meta

友情链接与广告

Free web proxy
Old friends:

NSClub: