Updated: 11 October 2026 · Applies to: Apache 2.4 (.htaccess)

Anyone can point a domain name at your server's IP address. If your site answers for every name, their domain shows your content, which can look like duplicate content to search engines. You can make your site answer only to your own domain.

With .htaccess

Add this at the top of the .htaccess file in your website's folder, with your own domain:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.)?example\.com$ [NC]
RewriteRule ^ - [F]

Requests for any other host name now get a "403 Forbidden" error. Add other domains that should work (aliases) to the condition, for example ^(www\.)?(example\.com|example\.net)$.

Note: On a shared IP address this is not needed: the web server only sends a domain to your site if it is set up in your account.

Related services

Managed cPanel VPS

cPanel included; we handle updates, security and monitoring.

cPanel server management

hardening, migrations and 24/7 monitoring, with no long-term contract.

cPanel, Plesk and LiteSpeed licences

for VPS and dedicated servers, with installation help on demand.

Was this answer helpful?

Still stuck? Open a ticket