Tryed to replayed AND with & or && but it just give me a error
“configuration file /etc/nginx/nginx.conf test failed”
and I am not allowed todo a if inside of a if
location = / {
if ($host = 'one.mysite.com' AND $arg_index = "") {rewrite ^
?index=site&id=1 permanent;}
if ($host = 'two.mysite.com' AND $arg_index = "") {rewrite ^
?index=site&id=2 permanent;}
}
If you end up guessing the config syntax, could you mention which docs
you read that were unclear? That way, hopefully, they can be fixed –
or the “right” docs made more findable – so that the next person with
the same difficulty will have an easier time. Thanks!
In nginx, “different host names” usually means “different server{}
blocks”. That way, you only have one if() condition to worry about,
which reduces it to a problem already solved
I realise this may be a simplified example, but: if “index” must always
be present and always equal to “site”, then perhaps whatever handles
the request could be told to assume that? This is similar to Igor’s
“don’t redirect; handle it internally” suggestion.
Maybe similar analysis will make your full application configuration be
clear too.
And the next question is about one.mysite.com and two.mysite.com each
redirecting to similar urls with different query strings.
I’ll reply to that one separately.
But different problems get different solutions. And if you don’t know
whether the problems are different (and the docs give no hint), then
it’s
good to ask about the problem you care about rather than a simplified
version that is possibly significantly different.