Simple rewrite (redirection)

Valentin V. Bartenev ne at vbart.ru
Wed Nov 23 20:17:28 UTC 2011


On Wednesday 23 November 2011 23:54:06 EricTheRed03 wrote:
> This is the block of code I've been working on for hours ... :(
> 
> --------------- 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

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



More information about the nginx mailing list