Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Htaccess blocking
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Htaccess blocking

t0p3at0p3a Member
edited January 2013 in General

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?

Comments

  • IntcsIntcs Member
    edited January 2013

    I'd try using:

    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.

  • From Stackoverflow:

    RewriteEngine on 
    Rewritecond %{HTTP_HOST} !^www\.maindomain\.com
    RewriteRule ^(.*)$ http://www.maindomain.com/$1 [R=301,L]
    
  • t0p3at0p3a Member
    edited January 2013

    I want to do exact the opposite redirect all domains except my main one to google

  • edited January 2013

    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.

  • t0p3at0p3a Member
    edited January 2013

    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?

Sign In or Register to comment.