Google Search has indexed my website's IP address and seems to be struggling with indexation overall (it was blocked with robots.txt directive for a bit).

I researched prior solutions and tried them, but the site IP still seems to provide a 200 status code when rendered in browser, and different HTTP header testing tools/crawlers (such as Screaming Frog) will inconsistently display a 200 or 301 code.

For reference, I am using SiteGround hosting (dedicated IP - the one that's indexed, this occurred after I switched from shared SiteGround hosting) and WordPress.

Are there additional settings I need to changes in the same or a different file?

The htaccess file code I tried to fix this with is (my website renders without the 'www' prefix fyi):

RewriteEngine On
RewriteCond %{HTTPS} off [OR] 
RewriteCond %{HTTP_HOST} ^www.example.com(.*)$ [NC] 
RewriteRule ^(.*)$ https://example.com$1 [R=301,L] 

My htaccess file also contains this additional code, which may be duplicate:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} on [OR]
RewriteCond %{SERVER_PORT} ^443$ [OR]
RewriteCond %{HTTP:X-Forwarded-Proto} https
RewriteRule .* - [E=WPR_SSL:-https]
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteRule .* - [E=WPR_ENC:_gzip]
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{QUERY_STRING} =""
RewriteCond %{HTTP:Cookie} !(wordpress_logged_in_.+|wp-postpass_|wptouch_switch_toggle|comment_author_|comment_author_email_) [NC]
RewriteCond %{REQUEST_URI} !^(/(?:.+/)?feed(?:/(?:.+/?)?)?$|/(?:.+/)?embed/|/(index.php/)?(.*)wp-json(/.*|$))$ [NC]
RewriteCond %{HTTP_USER_AGENT} !^(facebookexternalhit|WhatsApp).* [NC]
RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/wp-rocket/%{HTTP_HOST}%{REQUEST_URI}/index%{ENV:WPR_SSL}%{ENV:WPR_WEBP}.html%{ENV:WPR_ENC}" -f
RewriteRule .* "/wp-content/cache/wp-rocket/%{HTTP_HOST}%{REQUEST_URI}/index%{ENV:WPR_SSL}%{ENV:WPR_WEBP}.html%{ENV:WPR_ENC}" [L]
</IfModule>

Despite these rules, you can render the IP address in the browser, some crawlers will state it is a 200 status code, and it is indexed as a 200 status code URL.

1

There are 1 best solutions below

4
Stephen Ostermiller On

Because you have your own dedicated server, you should not be using .htaccess for this. You should be modifying the Apache web server configuration using virtual hosts. You should have a default virtual host that either shows a 404 error, or redirects to your site. Then you should have a virtual host that displays your site.

Showing an error page for the IP address is usually better than redirecting to your site. If you redirect to your site, than any host name that anybody points to your server will redirect to your site. Sometimes something unsavory gets pointed to your server.

See Block a random domain pointing at my dedicated IP for example configuration.