简体   繁体   English

亚马逊 | ELB 将启用 SSL 的 IP 重定向到域

[英]AWS | ELB Redirect SSL Enabled IP to Domain

I believe this is an important point and there is no help out there on the web.我相信这是一个重要的观点,网络上没有任何帮助。

Problem问题

I want to redirect my IP to the domain.我想将我的 IP 重定向到域。 for example, https://74.127.128.193/ and ELB URL hfgjg-77665555.ap-south-1.elb.amazonaws.com need to be 301 redirected to sample.com.例如, https: //74.127.128.193/ 和 ELB URL hfgjg-77665555.ap-south-1.elb.amazonaws.com 需要 301 重定向到 sample.com。

I want this because this IP and ELB URL is indexed by Google and instead of showing pages from domain google showing pages from that IP and ELB URL and marking many pages of the domain as duplicate because they are already index with IP address.我想要这个,因为这个 IP 和 ELB URL 是由 Google 索引的,而不是显示来自域 google 的页面,显示来自该 IP 和 ELB URL 的页面并将域的许多页面标记为重复,因为它们已经用 IP 地址索引了。

Tried Following试过以下

RewriteCond %{HTTP_HOST} ^74\.127\.128\.193$
RewriteRule ^(.*)$ http://google.com/$1 [L,R=301]

This is working but with http only, I mean this is redirecting IP to Domain when I open IP with http.这是有效的,但仅适用于 http,我的意思是当我使用 http 打开 IP 时,这是将 IP 重定向到域。

But his is not redirecting from IP to the domain when I open IP with https and Google has indexed IP with https not http.但是当我用 https 打开 IP 并且谷歌用 https 而不是 http 索引 IP 时,他没有从 IP 重定向到域。

I believe this is a huge problem in SEO and this is happening to everyone who is using AWS ELB with SSL, but they have not think about this or have not gone that deep as much I have gone.我相信这是 SEO 中的一个大问题,这发生在每个使用带有 SSL 的 AWS ELB 的人身上,但他们没有考虑过这个问题,或者没有像我那样深入。

Finally, I got it working.最后,我让它工作了。

Thanks for your reply guys.谢谢你的回复伙计们。

Google was showing my website has three different versions and it is hurting my website ranking since so long.谷歌显示我的网站有三个不同的版本,长期以来一直在损害我的网站排名。 My website content was showing in google with following.我的网站内容在谷歌中显示如下。

  1. Website IP address网站IP地址
  2. ELB URL ELB 网址
  3. My domain我的域

The above code in my question was actually working but when I was accessing IP with https in chrome it was asking for permission to open the URL and at that time IP was not redirecting to the domain but once I allow the permission it was redirecting successfully.我的问题中的上述代码实际上有效,但是当我在 chrome 中使用 https 访问 IP 时,它要求打开 URL 的权限,当时 IP 没有重定向到域,但是一旦我允许该权限,它就会成功重定向。

I have redirected from IP and ELB URL to domain successfully with following code in my htaccess file at top.我已使用顶部的 htaccess 文件中的以下代码成功地从 IP 和 ELB URL 重定向到域。

RewriteEngine On
RewriteCond %{HTTP_HOST} ^hfgjg-77665555\.ap-south-1\.elb\.amazonaws\.com$
RewriteRule (.*) https://sample.com/$1 [R=301,L]

RewriteEngine On
RewriteCond %{HTTP_HOST} ^74\.127\.128\.193
RewriteRule (.*) https://sample.com/$1 [R=301,L]

NOTE: This will permanently redirect all the internal pages as well to the domain注意:这将永久重定向所有内部页面以及域

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM