Answer the question
In order to leave comments, you need to log in
How to prevent a site from opening by IP?
Hello, I have a website on a specific domain. The domain hangs on the IP address (ns). The problem is that you can access the site by driving this IP into the browser. Google recently indexed this IP by accident and believes that the domain and this IP are duplicates, which actually affected the indexing.
How can I block access to a site by its IP? The first thing that came to my mind was to redirect to .htaccess, but there are probably better ways.
If it helps: hosting firstvds.ru, freebsd, is managed by ISPmanager.
Thank you.
Answer the question
In order to leave comments, you need to log in
And an even more correct way is to configure the Apache virtualhost so that it responds only from the desired hostname (it costs * instead of the domain, probably). Or make a 301 Moved Permanently redirect in .htaccess, since it is already indexed.
In the ISP manager panel, enter the IP address management and for the desired IP, assign another domain as the default domain.
301 redirect to htaccess
RewriteCond %{HTTP_HOST} ^ip address$ [NC]
RewriteRule ^(.*)$ domain/ $1 [R=301,L]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question