网站应该只加载其域名而不是 IP

网站应该只加载其域名而不是 IP

我的网站也加载了其 IP 地址,这对 SEO 不利。我如何才能限制我的 Apache 不这样做,并且只有我的域名请求才能访问该网站。

请参阅我的配置如下,

<VirtualHost *:80>
        ServerName mydomain.com
        ServerAlias www.mydomain.com
        ServerAdmin [email protected]
        DocumentRoot /var/www/html
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

"IP Canonicalization" Be careful, your server IP is not forwarding to your website's domain name. Search engines like Google™ are now able to index your website with its IP instead of its domain name. This will result in duplicate content.

To check this for your website, enter your IP address in the browser and see if your site loads with the IP address. Ideally, the IP should redirect to your website's URL or to a page from your website hosting provider.

If it does not redirect, you should do an htaccess 301 redirect to make sure the IP does not get indexed.

答案1

我不想告诉你这个,但 DNS 只是 IP 地址的掩码。据我所知,没有办法禁用 IP 连接,因为它也会阻止 DNS。

答案2

如果您在 Apache 中创建一个与默认虚拟主机分开的“NameVirtualHost”,那么 Apache 会将正确名称的请求定向到一个虚拟主机,并将其他请求定向到默认虚拟主机...默认虚拟主机可能包含错误,或重定向到正确的名称。

这是因为 Apache 会查看 HTTP 1.1 协议中的“Host:”标头来确定选择哪个虚拟主机。这还允许多个站点共享同一个名称。

但请注意,如果没有并不总是支持的附加协议扩展,它不适用于 SSL。

相关内容