Link to home
Start Free TrialLog in
Avatar of subtil
subtil

asked on

htaccess mod_rewrite based on day of the month

Dear experts

I wish to redirect my domain to subdomain using day of the month.
e.g
5th of the month redirect  ( abc.com and Anything.abc.com ) to five.abc.com
17th of the month redirect ( abc.com and Anything.abc.com )  to  seventeen.abc.com

If visitors type the following url on 5th:
www.abc.com  REDIRECT TO five.abc.com
abc.com REDIRECT TO  five.abc.com
direct.abc.com/download REDIRECT TO five.abc.com/download
whatever.abc.com/images/index.htm REDIRECT TO  five.abc.com/images/index.htm

Note:
If they type
five.abc.com on 6th, they will need to be redirect to six.abc.com as well

Currently i am trying with this codes, but there is a loop error
Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteCond %{TIME_DAY} ^1
RewriteRule ^(.*) http://one.abc.com/$1 [R=301,L]
RewriteCond %{TIME_DAY} ^2
RewriteRule ^(.*) http://two.abc.com/$1 [R=301,L]
RewriteCond %{TIME_DAY} ^3
RewriteRule ^(.*) http://three.abc.com/$1 [R=301,L]

List of subdomains
one.abc.com
two.abc.com
three.abc.com
four.abc.com
five.abc.com
six.abc.com
abc.com <- i am not using this
www.abc.com <- I am not using this

Thank you!
SOLUTION
Avatar of Steve Bink
Steve Bink
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of subtil
subtil

ASKER

Thanks!
Will look into it in deep.