rewrite help needed.

Igor Sysoev is at rambler-co.ru
Wed Aug 26 17:44:46 MSD 2009


On Wed, Aug 26, 2009 at 02:35:17PM +0100, Ian Hobson wrote:

> Igor Sysoev wrote:
> >On Wed, Aug 26, 2009 at 01:57:15PM +0100, Ian Hobson wrote:
> >
> >  
> >>Hi All
> >>
> >>I am trying to set up a wordpress site using nginx, and I am running 
> >>into trouble. Started with the page at 
> >>http://robertbasic.com/blog/wordpress-as-cms-tutorial/ 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]
> >></IfModule>
> >>
> >>This is the file in sites-available. / gives an empty reply, /blog gives 
> >>a 404, and index.php?p=1 gives a url of
> >>http://www.domain.com/blog/http:/www.domain.com/blog/hello-world/  and 
> >>the page contains  "No input file specified".
> >>
> >># Statements for domain.com
> >>server {
> >>   listen   80;
> >>   #
> >>   server_name domain.com www.domain.com ;
> >>   root /var/www/domain.com/htdocs;
> >>   access_log /var/www/domain.com/access.log 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;
> >>      break;
> >>   }
> >>   # 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/domain.com/passwords;
> >>   }
> >>   # all  .php requests to fastcgi using uri.
> >>   location ~ \.php$ {
> >>       include /etc/nginx/fastcgi_params;
> >>       fastcgi_pass 127.0.0.1:9000;
> >>   }
> >>}
> >>
> >>I suspect that the solution is really simple, but I can't see it.
> >>Help much appreciated.
> >>    
> >
> >    location /blog/ {
> >        try_files  $uri  $uri/  /index.php;
> >    }
> >
> >    location ~ \.php$ {
> >        include /etc/nginx/fastcgi_params;
> >        fastcgi_pass 127.0.0.1:9000;
> >    }
> >
> >  
> Thanks Igor for your super fast response.
> 
> I should have mentioned that I'm on ubuntu and therefore nginx 0.5.33  
> !  No try-files.
> 
> So I must either compile nginx on (unfamilar) ubuntu, or work round the 
> missing try-files.

    location /blog/ {
        error_page  404 = /index.php;
    }

    location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
    }


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list