BOA Best practice for 301 permanent redirects

Events happening in the community are now at Drupal community events on www.drupal.org.
tribe_of_dan's picture

Is there a BOA specific best practice for handling 301 permanent redirects?

Should I go down the path of using a rewrite in my site config or would creating a URL alias in Global Redirect module handle it better?

Comments

Nginx redirect is what i use

yazzou's picture

Nginx redirect is what i use and it is pretty useful if you detect patterns and use regex. It save time.

It is rather easy - you need

memtkmcc's picture

It is rather easy - you need to put your custom redirects in the extra Nginx config file, as explained in BOA docs: http://drupalcode.org/project/barracuda.git/blob/HEAD:/docs/HINTS.txt#l16 and restart Nginx.

An example for 301 redirect:

location ~* /some/path/regex {
  access_log off;
  rewrite ^ $scheme://$host/destiny/url permanent;
}

Thanks for that. I've already

tribe_of_dan's picture

Thanks for that. I've already made changes in my config file at .../vhost.d/www.website.com

Is there also a way, similar to nginx_vhost_include.conf, to include rewrites that apply to only 1 site and not all?

I'm afraid that my rewrites will be overwritten if somebody makes some changes in Aegir (such as adds a site alias or redirect). Thanks.

You should never edit vhost

memtkmcc's picture

You should never edit vhost files created and managed by Aegir. They will be overwritten on the next site verify anyway.

Yes, you can put site specific rewrites in the included extra config file, for example:

### site specific redirects
location ~* /some/path/regex {
  if ($host ~* ^(domain\.com)$) {
    rewrite ^ $scheme://$host/destiny/url permanent;
  }
  try_files $uri @cache;
}

Great, thanks for the info.

tribe_of_dan's picture

Great, thanks for the info. I've made the changes.

However, can you please confirm, will these be overwritten if I upgrade BOA later on?

Hello! When I put your code

Alex Bacart's picture

Hello!
When I put your code from #641293 to /var/aegir/config/server_master/nginx/post.d/nginx_vhost_include.conf and try to reload nginx I get an error:
nginx: [emerg] "location" directive is not allowed here in /var/aegir/config/server_master/nginx/post.d/nginx_vhost_include.conf
Can you tell me what am I doing wrong? Thanks.

BOA

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: