rewrite difficulty
Tseveendorj Ochirlantuu
tseveendorj at gmail.com
Thu Aug 1 07:11:05 UTC 2013
Hello,
My understanding is on Apache rules like follow and convert it to nginx
If anyone request anything except follow URI /file/, /install/, /design/,
/plugins/, /phpmyadmin/ then nginx will forward anything to
/index.php?do=anything
RewriteCond %{REQUEST_URI} !^/file/.*
RewriteCond %{REQUEST_URI} !^/install/.*
RewriteCond %{REQUEST_URI} !^/design/.*
RewriteCond %{REQUEST_URI} !^/plugins/.*
RewriteCond %{REQUEST_URI} !^/phpmyadmin/.*
RewriteRule ^(/.*)$ /index.php?do=$1 [L]
nginx
location / {
if ( $request_uri !~ ^(/file/|/install/|/design/|/plugins/|/phpmyadmin/)) {
rewrite ^(/.*)$ /index.php?do=$1;
}
}
Is this right ? It works on my server. I'm confusing where I need to put
this rewrite. Am I right ?
On Tue, Apr 30, 2013 at 10:01 AM, Jonathan Matthews <contact at jpluscplusm.com
> wrote:
> On 30 April 2013 03:36, tseveendorj <tseveendorj at gmail.com> wrote:
> > Hello,
> >
> > I have difficulty to convert apache like rewrite to nginx. This is my
> config
> > file of virtualhost on nginx. http://pastebin.com/HTtKXnFy
>
> OMFG. You win today's prize for "Nginx config I am least likely even
> to /try/ and change". Congrats! ;-)
>
> > My installed php script should have following rewrite
> > http://pastebin.com/M2h3uAt3
> >
> > Currently any requested php code displayed it's source on browser. How
> could
> > I migrate ?
>
> You need to start small. Learn how Nginx does its thing in one small
> area and when you've understood that, move on the next.
>
> At the moment, you have literally picked up your apache config and
> dumped it into Nginx's config syntax. You are unlikely to succeed if
> you don't learn how to work *with* Nginx, instead of trying just to
> make it behave like Apache.
>
> This may not be the "here's your config; I fixed it" reply you were
> looking for, but it's the best I can give you. Your Nginx config is
> /horrible/, and I'm not going to spend my time deciphering it! :-)
>
> Have a *really* good read of
> http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite and
> http://wiki.nginx.org/HttpRewriteModule. They'd be good places to
> start ...
>
> J
> --
> Jonathan Matthews // Oxford, London, UK
> http://www.jpluscplusm.com/contact.html
>
> _______________________________________________
> 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/20130801/25a70e6c/attachment.html>
More information about the nginx
mailing list