Answer the question
In order to leave comments, you need to log in
How to prevent a site from opening on all domains except site.com?
Set up default VirtualHost in apache to your domain.
> But, unknown people created a domain and tied it to the ip of my server and my site began to appear on their domain.
How can I prevent the site from opening on all domains except mine?
<VirtualHost 123.123.123.123:80>
ServerName www.site.com
ServerAlias site.com
ServerAdmin [email protected]
DocumentRoot /var/www
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Answer the question
In order to leave comments, you need to log in
More or less like this:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.site\.com$ [nocase]
RewriteRule ^(.*)$ http://www.site.com$1 [last,redirect=301]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question