Howdy, Stranger!

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


Shells Virtual Desktop
BMail.ag - Secure Email Service
Server.net
CPLicense.net
VPS Server
Buy VPN
Vultr
VMs for AI
HostDare
ReliableSite White-Label Dedicated Hosting for Resellers
InterServer VPS
BMail.ag - Secure Email Service
Best VPN
High-Performance Bare Metal Server Solutions
Karvl.com
Server Mania Cloud Hosting
DataWagon Hosting
AlphaVPS Hosting
Evoxt.com
Clouvider
VPS Hosting with NVMe
Residential IPs in the US & 4G Mobile Proxies in EU & US with Unlimited Bandwidth
ReliableSite White-Label Dedicated Hosting for Resellers
Rabisu - Hosting Solutions
Shells Virtual Desktop
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.