M
M
makecode2011-03-19 21:03:31
Network administration
makecode, 2011-03-19 21:03:31

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

5 answer(s)
S
slang, 2011-03-19
@slang

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.

A
Artqookie, 2011-03-19
@Artqookie

.htaccess is the correct way.

D
Dzuba, 2011-03-19
@Dzuba

In the ISP manager panel, enter the IP address management and for the desired IP, assign another domain as the default domain.

M
mihavxc, 2011-03-20
@mihavxc

301 redirect to htaccess
RewriteCond %{HTTP_HOST} ^ip address$ [NC]
RewriteRule ^(.*)$ domain/ $1 [R=301,L]

J
Jazzist, 2011-03-19
@Jazzist

htaccess or nginx rules

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question