Simple rewrite (redirection)

Hi Guys,

In my HTTP config section in the config file, I would like to implement
a redirection based on this scenario:

If the URL is not “http://sitea.com/exactmatch” then redirect to the
“https” home. else go to our hidden url (our testing boxes)

#logic would be somthing like this…
If (The URL is anything but “/ahiddenurl”)
{
go to “https://sitea.com
}
else
{
go to “http://hiddenurl
}

Is this possible in the nginx.conf file?? Any help would be so very much
appreciated!

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

This is the block of code I’ve been working on for hours … :frowning:

--------------- nginx.conf ------------
server {
listen 80;
server_name sitea.com;
rewrite ^(/hiddendevpath)(.)$ http://sitea.com/ ;
rewrite ^(.
) https://sitea.com
}

------------- testing below ----------

sudo /usr/sbin/nginx -t
Error: nginx: [emerg] invalid number of arguments in “rewrite” directive
in /etc/nginx/nginx.conf:44

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

On Wednesday 23 November 2011 23:54:06 EricTheRed03 wrote:

------------- testing below ----------

sudo /usr/sbin/nginx -t
Error: nginx: [emerg] invalid number of arguments in “rewrite” directive
in /etc/nginx/nginx.conf:44

You forgot a ; at the end of this directive:
rewrite ^(.*) https://sitea.com

Try this:

server {

listen  80;
server_name sitea.com;

location /hiddendevpath {
  rewrite  ^  https://sitea.com/;
}

}

wbr, Valentin V. Bartenev

On Wed, Nov 23, 2011 at 02:46:13PM -0500, EricTheRed03 wrote:

{
go to “https://sitea.com
}
else
{
go to “http://hiddenurl
}

Is this possible in the nginx.conf file?? Any help would be so very much
appreciated!

server {
listen 80;
server_name sitea.com;

location / {
    return https://sitea.com;
}

location /hiddenurl {
    ...
}

}


Igor S.

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