Problem with simple rewrite rule

Tieg Zaharia tieg.zaharia at gmail.com
Sun Mar 9 22:24:58 MSK 2008


I think the first problem is that you're redirecting to wiki.php instead of
to the "/WIKIPAGE" url. As I found out last week, replacing query strings in
nginx can be tricky. Does this work? (it won't work with more query string
params)

server {
  if ($query_string ~ ^wiki=(.*)$) {
    rewrite ^(.*)$ /$1 break;
  }
}

-tieg

On Sun, Mar 9, 2008 at 3:01 PM, Per Hans Hansen <pehaha at gmail.com> wrote:

> I try to create a very simple rewrite rule with nginx, but i doesnt work.
>
> I have set up my server with a "catch all" server_name *.mydomain.com
>
> I then try to create a rewrite rule so that requests to
> mysubdomain.mydomain.com/wiki.php?wiki=WIKIPAGE will be rewritten to
> mysubdomain.mydomain.com/WIKIPAGE
>
> Here is the option that i thought would work:
>
>        server {
>              server_name mysubdomain.domain.com;
>              if (!-e $request_filename) {
>              rewrite ^/(.*)$ /wiki.php?wiki=$1 last;
>              }
>         }
>
> Suggestions to why this does not work are highly appreciated.
>
> Thanks,
> per
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20080309/b7c11385/attachment.html>


More information about the nginx mailing list