rewrite help needed.

Ian Hobson ian at
Wed Aug 26 16:57:15 MSD 2009

Hi All

I am trying to set up a wordpress site using nginx, and I am running 
into trouble. Started with the page at but things are 
not working. I think that my translation
oh an .htaccess file is wrong.

This is the Apache .htaccess file I wish to replace..

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]

This is the file in sites-available. / gives an empty reply, /blog gives 
a 404, and index.php?p=1 gives a url of  and 
the page contains  "No input file specified".

# Statements for
server {
    listen   80;
    server_name ;
    root /var/www/;
    access_log /var/www/ combined;
    index index.php index.html index.htm;
    # redirect server error pages to the static page /50x.html
    error_page   500 502 503 504  /50x.html;
    # serve static files
    if (-f $request_filename) {
       # expires 30d;
    # send all non-existing file or directory requests to index.php
    if (!-e $request_filename) {
        rewrite ^/blog/(.+)$ index.php?q=$1 last;
    # password protect /usage
    location ^~ /usage/ {
        auth_basic "Please login";
        auth_basic_user_file /var/www/;
    # all  .php requests to fastcgi using uri.
    location ~ \.php$ {
        include /etc/nginx/fastcgi_params;

I suspect that the solution is really simple, but I can't see it.
Help much appreciated.


More information about the nginx mailing list