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:

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:

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:

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:

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

Posted at Nginx Forum: