


























First you have to decide whether the redirect will be permanent (301), or just temporary (302). If you are uncertain, just pick temporary and switch later.
Use cases from my understanding:
301 redirects:302 redirect:Both do the same, but still have their use cases. Switching them up could cause problems with various indexes of search engines, SEO, wrongly being flagged as a spammer, and so on.
For this example, I am going to use temporary 302 redirects.
server {
listen 80;
listen 443;
server_name test2.brrl.net;
location / {
return 302 https://www.youtube.com/watch?v=dQw4w9WgXcQ;
}
}
That is a simple redirect of the root of the sub-domain. Try it out: https://test2.brrl.net.
If you want to create a redirection of a subdirectory like /status, simply change it accordingly:
server {
listen 80;
listen 443;
server_name brrl.net;
location /status {
return 302 https://status.brrl.net/status/overview;
}
}
With this config block, only the subdirectory /status would be redirected. For example: https://brrl.net/status redirects to https://status.brrl.net/status/overview.
There are many more forms of redirects, but I am familiar enough to write about that. I might add more redirects later on, but I'll have to test beforehand.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。