Rewrite difficulty

Hello,

I have difficulty to convert apache like rewrite to nginx. This is my
config file of virtualhost on nginx. server { listen 80; server_name 192.168.1.2; - Pastebin.com

My installed php script should have following rewrite

Currently any requested php code displayed it’s source on browser. How
could I migrate ?

Thanks.

On 30 April 2013 03:36, tseveendorj [email protected] wrote:

Hello,

I have difficulty to convert apache like rewrite to nginx. This is my config
file of virtualhost on nginx. server { listen 80; server_name 192.168.1.2; - Pastebin.com

OMFG. You win today’s prize for “Nginx config I am least likely even
to /try/ and change”. Congrats! :wink:

My installed php script should have following rewrite
RewriteEngine OnRewriteCond %{REQUEST_URI} !^/mnub2010/file/.*RewriteCond - Pastebin.com

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! :slight_smile:

Have a really good read of
Module ngx_http_rewrite_module and
Module ngx_http_rewrite_module. They’d be good places to
start …

J

Jonathan M. // Oxford, London, UK
http://www.jpluscplusm.com/contact.html

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 M.
<[email protected]