Permanent Redirect on nginx

Mumanyi, Bravismore bmumanyi at unam.na
Thu Apr 28 14:47:03 UTC 2016


Dear Nginx Community

My org has changed domain from unam.na to unam.edu.na. I intend to effect a permanent redirect on Nginx.

I have tried the lines in bold below but browsers are complaining of too many redirects.

Any tips on how I can adjust the config file for permanent redirect?

-----------------------Complete config file under sites-enabled---------------------------------------

server {

  listen 80;
  root /usr/share/nginx/atom;

  # http://wiki.nginx.org/HttpCoreModule#server_name
  # _ means catch any, but it's better if you replace this with your server
  # name, e.g. archives.foobar.com
  server_name _;
  #server_name archives.unam.na;
  #return 301 $scheme://archives.unam.edu.na;

  #server_name archives.unam.na;
  #rewrite ^ http://archives.unam.edu.na$request_uri? permanent;

  client_max_body_size 72M;

  # http://wiki.nginx.org/HttpCoreModule#try_files
  location / {
    try_files $uri /index.php?$args;
  }

  location ~ /\. {
    deny all;
    return 404;
  }

  location ~* (\.yml|\.ini|\.tmpl)$ {
    deny all;
    return 404;
  }

  location ~* /(?:uploads|files)/.*\.php$ {
    deny all;
    return 404;
  }

  # This is the most important part, as here we are redirecting some specific
  # requests to PHP-FPM so PHP can do its job passing data to and from the
  # web server.
  location ~ ^/(index|qubit_dev)\.php(/|$) {
    include /etc/nginx/fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    fastcgi_pass unix:/var/run/php5-fpm.atom.sock;
  }

  location ~* \.php$ {
    deny all;
    return 404;
  }

}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20160428/f3b3e367/attachment.html>


More information about the nginx mailing list