Rerwrite problem

abc.com/nginx.text rewrite www.abc.com/nginx.text
service_name abc.com www.atans.com
if ($host = ‘abc.com’ ) {
rewrite ^/(.*)$ http://www.abc.com/$1 permanent;
}

Is this rewrite rule right?

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,40554,40554#msg-40554

reload display error
: unknown directive “if($host==“atans.cn”)” in /etc/nginx/nginx.conf:110
configuration file /etc/nginx/nginx.conf test failed

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,40554,40557#msg-40557

if($host!=‘www.abc.com’){
rewrite ^/(.*)$ http://www.abc.com/$1 permanent;
}
why has this error
: unknown directive “if($host!=‘www.abc.com’)” in
/etc/nginx/nginx.conf:110
configuration file /etc/nginx/nginx.conf test failed

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,40554,40559#msg-40559

its better to use solution like this

server {
listen 80;
server_name abc.com;
access_log off;
rewrite ^ http://www.abc.com$request_uri permanent;
}

server {
listen 80:
server_name www.abc.com;
#rest of server config
}

V/r,
Rob S.

On Wed, Jan 13, 2010 at 10:10 AM, lnxa [email protected] wrote:

abc.com/nginx.text rewrite  www.abc.com/nginx.text
 service_name abc.com www.atans.com
 if ($host = ‘abc.com’ ) {
    rewrite  ^/(.*)$  http://www.abc.com/$1  permanent;
  }

Is this rewrite rule right?

create different server block for each domain


O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

lnxa ha scritto:

It is great!
thanks!
why if($host!=‘www.abc.com’) not work?

it should be !~ instead of !=
but using if for $host is very inefficient and as suggested you before
create different server block for each domain is the best solution.

Bye
Daniele

On Tue, Jan 12, 2010 at 10:59:10PM -0500, lnxa wrote:

It is great!
thanks!
why if($host!=‘www.abc.com’) not work?

Look also
http://nginx.org/en/docs/http/converting_rewrite_rules.html


Igor S.
http://sysoev.ru/en/

Yes
There is a apace between if and ($host …)

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,40554,223466#msg-223466

It is great!
thanks!
why if($host!=‘www.abc.com’) not work?

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,40554,40569#msg-40569

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs