Setting up Tweet Nest in Nginx

Today I've set up Tweet Nest at tweets.tenzer.dk. Tweet Nest is a simple application which archives all your tweets, and makes it easy to search for old tweets you've written that you might want to find again. Tweet Nest comes by default with .htaccess files containing a Apache mod_rewrite specific configuration, but since I'm using Nginx that configuration won't work for me.

The mod_rewrite rules a limited to rules for handling requests to /sort, /favorites, /search and pages to show tweets for a specific month and day. In the .htaccess file they are specified as:

RewriteEngine On
RewriteRule ^sort/?$ ./sort.php [L]
RewriteRule ^favorites/?$ ./favorites.php [L]
RewriteRule ^search/?$ ./search.php [L]
RewriteRule ^([0-9]+)/([0-9]+)/?$ ./month.php?y=$1&m=$2
RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)/?$ ./day.php?y=$1&m=$2&d=$3

I have replaced those with the following Nginx rules, which are specified within the server {} directive for tweets.tenzer.dk:

rewrite  ^/sort /sort.php;
rewrite  ^/favorites /favorites.php;
rewrite  ^/search /search.php;
rewrite  ^/([0-9]+)/([0-9]+)/([0-9]+)? /day.php?y=$1&m=$2&d=$3;
rewrite  ^/([0-9]+)/([0-9]+)? /month.php?y=$1&m=$2;

A few things to note:

A fun thing, if you try to find my first tweet, you will see that the oldest tweet in the archive is dated to October 13th, 2001 which can't be right, since Twitter didn't launch until 2006. It must be Twitter who got it wrong in their database, because that's also the date shown on their page for the tweet.

Comments

One Response to “Setting up Tweet Nest in Nginx”

  1. Gregoire_M on March 27th, 2013 19:59

    Thank you for this translation.
    But what about the .htaccess located in the maintenance directory? (I don't know if it's useful)

Leave a Reply