Hello all.
I have a problem. You know - browsers are not so clever. If you write a link with . at the end (ex github.com.) you'll have problems. It can be...anything. Not working cookie, missed link, e.t.c. Nginx (and Tengine) corrects $host and remove bugs from it. So when i try to use return 301 or rewrite it don't works. Because configs don't see '.' at the end.
My please is to do a config value:
correct_uri_path on/off;
Thanks in advance,
Alex.
4条答案
按热度按时间mctunoxg1#
Do you wan to keep the last dot in the host?
I just do a experiment. It works for me:
My config is like this:
I'm curious why do you want such behaviour?
yc0p9oo02#
You did not understand.
If user adds (probably by mistake) dot at the end - there will be problem's on the website. It can be any. Cookie mismatch, search engines aggresive, 404. Anyway user will leave your website.
I want to use
server {
}
zyfwsgd63#
Can you use the variable
$http_host
instead? It could be exactly the same host name in the http header. You can rediect the wrong host request like this:aij0ehis4#
Can you use the variable $http_host instead? It could be exactly the same host name in the http header. You can rediect the wrong host request like this:
It works like a charm, thanks.
How do you think - it is fine for most workloads to redirect all GET and HEAD requests with dot at the end to request without dot? For example "domain.com/image.jpg." redirect to "domain.com/image.jpg"?
If yes, can you give most correct (from nginx prespective) and performant code to realize that?