Apache 重定向到 IP 地址(非 URL)

won*_*wan 1 ip https redirect apache-2.2

我一直在尝试通过将以下行添加到文件中来将 Web 流量从HTTP重定向到HTTPShttpd.conf

Redirect permanent / https://100.100.100.100
Run Code Online (Sandbox Code Playgroud)

但无济于事。浏览器响应是Firefox has detected that the server is redirecting the request for this address in a way that will never complete

我知道它适用于域名,但我的服务器不使用域名。有什么办法可以解决这个问题/我做错了什么。

Lad*_*ada 5

我怀疑您的 Redirect 行位于影响 SSL 和非 SSL 部分的配置文件的一部分中。因此,即使您请求 SSL 版本,您仍然会重定向到 SSL 版本。

如果您有一部分仅用于非 SSL 的配置文件,请将重定向移动到那里。如果没有,请将其转换为 RewriteRule 并在其前面使用 RewriteCond,如下所示:

RewriteCond %{HTTPS} off
RewriteRule / https://100.100.100.100/ [R=301]
Run Code Online (Sandbox Code Playgroud)