HTA – Redirect everyone for site maintenance

Version: 13.2
Revision: 34 Build 13

HTA – Redirect everyone for site maintenance.

Introduction:
When I was checking my email, I had a request from a university student.
He’s asking me for help about blocking users from an old domain and redirecting them to a new domain. But, he wants to check his old domain, while the other users is redirected to his new domain.

Notes: this is also useful if you want to tell “Google Engine” if you are changing domain names.

Alright, this is kind of dificult for coders. But, it does work if you know how to construct it.
It’s like Chess & Checkers! It means, you have to create codes from trails and errors. Ofcourse, HTA script is not that hard, if you study VBScript and think of these codes as physics equations.

Anyway, if anybody wants to use this script, you must have a “Static IP Address” with HTA engine enabled.
If you haven’t got HTA engine, then you’ll need to consult this problem with your hosting provider.

Warning: if you want to check your old domain, you must input the correct IP address (your IP Address), or else, you be redirected to your new domain.
But, if you want to keep this script, forever. You’ll need to comment out the “Remote Address”. Just add ‘#’ before the codes. But, this is only acceptable if you still own the previous domain name. Nevertheless, if you have SSL encryption, please use the ones that has: “https” – labeled.

Caution *1: if there is a problem with the script, please remove “R=301″ and replace it with “R”.
Caution *2: if your website has SSL, please comment “HTTP_HOST” and remove the comments for “SERVER_PORT”.

Notes: to use everything as default, just use the ones below and replace your domain names with yours.

HTA – Redirect everyone to a new domain (accept you).
———— Copy Text —————

RewriteEngine On
Options +FollowSymLinks
# This is where you add your IP address.
RewriteCond %{REMOTE_ADDR} !^1\.2\.3\.4$
#---------------------
# This is use if your hosting provider requires ports.
# RewriteCond %{SERVER_PORT} 80 [NC,OR]
# RewriteCond %{SERVER_PORT} 443 [NC]
# RewriteCond %{REQUEST_URI} example
#---------------------
# Match a specific domain OR sub domain (if it exist).
RewriteCond %{HTTP_HOST} ^(.+\.)?example\.co\.uk$ [NC,OR]
RewriteCond %{HTTP_HOST} ^(.+\.)?example\.co\.cc$ [NC]
# %1 is the sub domain (or empty).
RewriteRule ^(.*)$ http://%1example.net/$1 [R=301,L]
# RewriteRule ^(.*)$ https://%1example.net/$1 [R=301,L]

———— End —————

Notes: if you don’t have SSL and the above looks complicated, please use this instead of the above.
———— Copy Text —————

RewriteEngine On
Options +FollowSymLinks
# This is where you add your IP address.
RewriteCond %{REMOTE_ADDR} !^1\.2\.3\.4$
# Match a specific domain OR sub domain (if it exist).
RewriteCond %{HTTP_HOST} ^(.+\.)?example\.co\.uk$ [NC,OR]
RewriteCond %{HTTP_HOST} ^(.+\.)?example\.co\.cc$ [NC]
# %1 is the sub domain (or empty).
# %2 is SSL encryption (or disabled)
RewriteRule ^(.*)$ http://%1example.net/$1 [R=301,L]

———— End —————

Copyrighted By Lair360

Comments are closed.