Answer the question
In order to leave comments, you need to log in
How to set up a redirect to Nginx/Ghost?
There is a blog on the Egeya engine.
Links are in this format:
domain.com/?go=all/article-name-hello-world/
domain.com/?go=all/note-name-hi-kitty/
...
domain.com/?go=all/note-name-hi-kitty/
domain.com/2014/12/23/note-name-hi-kitty/
rewrite ^/?go=all/(.*)$ domain.com/$1 permanent;
rewrite ^/\?go=all/(.*)$ domain.com/$1 permanent;
rewrite ~*/\?go=all/(.*)$ domain.com/$1 permanent;
/hello-kitty/ HTTP/1.1", host: "domain.com"
2015/02/10 05:45:16 [notice] 2300#0: *73 "^/?go=all/(.*)$" does not match "/", client: 127.0.0.1, server: 127.0.0.1, request: "GET /?go=all/hello-kitty/ HTTP/1.1", host: "domain.com"
2015/02/10 05:45:16 [notice] 2300#0: *73 "^/\?go=all/(.*)$" does not match "/", client: 127.0.0.1, server: 127.0.0.1, request: "GET /?go=all/hello-kitty/ HTTP/1.1", host: "domain.com"
2015/02/10 05:45:16 [notice] 2300#0: *73 "~*/\?go=all/(.*)$" does not match "/", client: 127.0.0.1, server: 127.0.0.1, request: "GET /?go=all/hello-kitty/ HTTP/1.1", host: "domain.com"
Answer the question
In order to leave comments, you need to log in
I would do like this:
map $arg_go $new_url {
default "";
all/note-name-hi-kitty/ /2014/12/23/note-name-hi-kitty/;
all/article-name-hello-world/ /2014/01/01/article-name-hello-world/;
# тут остальные ссылки
}
server {
listen 80;
server_name example.com;
location = / {
if ($new_url) {
return 301 $new_url;
}
# тут какой-то конфиг для корня
}
# всё остальное
Something has changed, but it doesn't work as it should yet:
the request
redirects to
/etc/nginx/sites-enabled/ghost
map $arg_go $new_url {
default "";
all/note-name-hi-kitty/ /2014/12/23/note-name-hi-kitty/;
all/article-name-hello-world/ /2014/01/01/article-name-hello-world/;
# тут остальные ссылки
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name 127.0.0.1;
#redirect for old links
location = / {
if ($new_url) {
return 301 $new_url;
}
}
root /usr/share/nginx/html;
index index.html index.htm;
client_max_body_size 10G;
location / {
proxy_pass http://localhost:2368;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question