Posted by tribe_of_dan on November 12, 2011 at 12:26pm
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
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
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
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
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 redirectslocation ~* /some/path/regex {
if ($host ~* ^(domain\.com)$) {
rewrite ^ $scheme://$host/destiny/url permanent;
}
try_files $uri @cache;
}
Great, thanks for the info.
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
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.