I have multiple domains pointing to my IP they are all A records how can i block them using htaccess and redirect to google when traffic is coming from one of those domains?
Redirect 'redirected url or local directory here' 'where you want to redirect to here'
If it didn't work, then as you look using Apache then maybe you have to create a virtual server for each domain just like if you are hosting them "shared" on your server with a dedicated website for each domain, but then redirect them as above using an .htaccess file in the /Home directory of each domain/virtual server.
You can edit that as required; whether or not you want to pass the path/variables/etc. Add multiple RewriteCond lines if you have multiple domains within that VirtualHost which you don't want redirected.
Sounds good but it does not work it redirects all domains
This is the setup i have for reference:
BADDomain.com A Record my SERVER IP > redirect google htaccess
BADDomain2.com A Record my SERVER IP > redirect google htaccess
Gooddomain A Record my SERVER IP > don't redirect
So if someone is coming from baddomain should be redirected if he comes from gooddomain nothing should happen
Comments
I'd try using:
If it didn't work, then as you look using Apache then maybe you have to create a virtual server for each domain just like if you are hosting them "shared" on your server with a dedicated website for each domain, but then redirect them as above using an .htaccess file in the /Home directory of each domain/virtual server.
From Stackoverflow:
RewriteEngine on Rewritecond %{HTTP_HOST} !^www\.maindomain\.com RewriteRule ^(.*)$ http://www.maindomain.com/$1 [R=301,L]I want to do exact the opposite redirect all domains except my main one to google
Setup the domains as ServerAlias within the VirtualHost and use the rule...
RewriteCond %{HTTP_HOST} !primarydomain\.com [NC]RewriteRule ^(.*)$ http://www.google.com [R,L]You can edit that as required; whether or not you want to pass the path/variables/etc. Add multiple RewriteCond lines if you have multiple domains within that VirtualHost which you don't want redirected.
Sounds good but it does not work it redirects all domains
This is the setup i have for reference:
BADDomain.com A Record my SERVER IP > redirect google htaccess
BADDomain2.com A Record my SERVER IP > redirect google htaccess
Gooddomain A Record my SERVER IP > don't redirect
So if someone is coming from baddomain should be redirected if he comes from gooddomain nothing should happen
do you need to redirect to google.com or is it just an example. Do you really need to redirect at all?