首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >nginx:[警告]服务器名有带有长域重定向的可疑符号

问nginx:[警告]服务器名有带有长域重定向的可疑符号
EN

Server Fault用户
提问于 2022-10-19 19:20:50
回答 1查看 120关注 0票数 0

在Nginx中重定向两个长域URLS的最佳方法是什么,我想在两个域之间配置一个重定向,如下所示:

我相信这之前有人问过,但我找不到一个可行的解决方案。

代码语言:javascript
复制
original link:

https://qwerty.test.com/education/7/abc-science

New link

https://www.test.com/education/7/abc-science

我试过这样做:

代码语言:javascript
复制
server {
    listen 80;
    listen 443 ssl;
    server_name qwerty.test.com/education/7/abc-scienc;
    return 301 $scheme://www.test.com/education/7/abc-science$request_uri;
}

仍然会收到一些错误

代码语言:javascript
复制
nginx: [warn] server name "education/7/abc-scienc
" has suspicious symbols in /etc/nginx/conf.d/redirect.conf:9

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

重复问题如下:https://stackoverflow.com/questions/74101316/long-url-diffrent-domain-redirect-nginx-issue

这些变化对我有用吗?

代码语言:javascript
复制
server {
    listen 80;
    server_name www.test.com;
    #old url
    location /education/7/abc-science {
        # Unique handler for the URL you want to redirect.
        # new url
        return 301 $scheme://www.test.com/education/7/abc-science;
    }
}

还是需要在location块中添加$request_uri?

我是否需要使用这种方式将原来的URL重定向到新的URL?

代码语言:javascript
复制
location = /content/unique-page-name {
  return 301 /new-name/unique-page-name;
}

有人能帮我吗?这里怎么了?

任何帮助都是非常感谢的!谢谢!

EN

回答 1

Server Fault用户

发布于 2022-10-19 20:23:05

nginx文档声明server_name是虚拟主机的虚拟服务器名(域名)。

文档还解释了在那里允许什么样的输入。

您正在尝试添加URL而不是域,这就是配置无效的原因。

您需要为URL的URI部分添加一个location块。

票数 0
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/1113517

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档