Rewrite conversion

Tseveendorj Ochirlantuu tseveendorj at gmail.com
Sat Jul 23 07:31:51 UTC 2011


Dear Igor,

Thank you for your conversion. It is working now.
I never imagine this apache rewrite would be like this.

Thank you very much again.

Tseveen.


On Sat, Jul 23, 2011 at 4:18 PM, Igor Sysoev <igor at sysoev.ru> wrote:

> On Sat, Jul 23, 2011 at 04:07:27PM +0900, Tseveendorj Ochirlantuu wrote:
> > Hello,
> >
> > I'm trying to convert from apache to nginx rewrite.
> >
> > ErrorDocument 403 /index.php?do=/public/error/403/
> > ErrorDocument 404 /index.php?do=/public/error/404/
> >
> > RewriteEngine On
> >
> > RewriteCond %{REQUEST_URI} !^/file/.*
> > RewriteCond %{REQUEST_URI} !^/install/.*
> > RewriteCond %{REQUEST_URI} !^/design/.*
> > RewriteCond %{REQUEST_URI} !^/plugins/.*
> > RewriteRule ^index.php(/.*)$ /index.php?do=$1 [L]
> >
> > RewriteCond %{REQUEST_URI} !^/file/.*
> > RewriteCond %{REQUEST_URI} !^/install/.*
> > RewriteCond %{REQUEST_URI} !^/design/.*
> > RewriteCond %{REQUEST_URI} !^/plugins/.*
> > RewriteCond %{REQUEST_URI} !^/index.php
> > RewriteCond %{REQUEST_URI} !^/robots.txt
> > RewriteCond %{REQUEST_URI} !^/favicon.ico
> > RewriteRule ^(.*)$ /index.php?do=/$1 [L]
> >
> >
> > This is my try :D
> >
> > error_page 403 /index.php?do=/public/error/403/;
> > error_page 404 /index.php?do=/public/error/404/;
> >
> > rewrite ^index.php(/.*)$ /index.php?do=$1 last;
> > rewrite ^(.*)$ /index.php?do=/$1 last;
> >
> > I have difficulty on REQUEST_URI with following paths.
> >
> > any help is appreciated.
>
> server {
>    ...
>
>    root  /path/to/files;
>
>    error_page 403  /index.php?do=/public/error/403/;
>    error_page 404  /index.php?do=/public/error/404/;
>
>     location /file/ {
>    }
>
>    location /install/ {
>    }
>
>    location /design/ {
>    }
>
>    location /plugins/ {
>    }
>
>    location = /robots.txt {
>    }
>
>    location = /favicon.ico {
>    }
>
>    location / {
>        fastcgi_pass   ...
>        include        fastcgi_params;
>        fastcgi_param  SCRIPT_FILENAME  /path/to/files/index.php;
>        fastcgi_param  QUERY_STRING     do=$uri;
>    }
>
>    location /index.php {
>
>        location = /index.php {
>            fastcgi_pass   ...
>            include        fastcgi_params;
>            fastcgi_param  SCRIPT_FILENAME  /path/to/files/index.php;
>            fastcgi_param  QUERY_STRING     $args;
>        }
>
>        location ~ ^/index.php(/.*)$ {
>            fastcgi_pass   ...
>            include        fastcgi_params;
>            fastcgi_param  SCRIPT_FILENAME  /path/to/files/index.php;
>            fastcgi_param  QUERY_STRING     do=$1;
>        }
>
>        return 404;
>    }
>
>
> --
> Igor Sysoev
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20110723/099a22f4/attachment-0001.html>


More information about the nginx mailing list