motioz
motioz

Reputation: 662

htaccess allow only right domain name in ip dedicated website

i'm trying to allow only my domain name to view my website... i have a dedicated ip and Anyone can basically set your domain to my ip, It creates duplicate content of my website.

Upvotes: 0

Views: 570

Answers (3)

mrraka
mrraka

Reputation: 133

Try this code, it will rewrite all domain names used to access your site to the correct one:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]

This means that everything that do not match the www.domain.com will be redirected/rewrited to www.domain.com.

Upvotes: 1

Henk
Henk

Reputation: 11

As far as i know the host will only respond to the correct domainnames configured.

You could also make sure with htaccess that all incoming request get rewrited to the correct domain.

As in this example .domain.com is rewited to www.domain.com and will never be available the other way arround.

http://www.tech-recipes.com/rx/296/rewrite-domaincom-to-wwwdomaincom-using-htaccess-in-apache/

Upvotes: 0

deceze
deceze

Reputation: 522155

Am I understanding you correctly that you are worried that other people will point their domain to your IP, thereby lowering your SEO ratings? First of all: wow. Secondly: configure the web server with virtual hosts to respond to a particular domain name only, not to all requests regardless of HTTP Host header. How to do this exactly depends on what web server you're running exactly and whether you can configure virtual hosts on it.

Upvotes: 0

Related Questions