Redirect domain by Ip , help me please?

Using a single web hosting account to host multiple sites

Redirect domain by Ip , help me please?

Postby huyhoa » Fri Jan 12, 2007 11:09 pm

I use this, that mean, i want the visitor from below Ip will redirect to dmtcenter.com and other will redirect to huyhoa.biz
#Ngan cam IP Vietnam

RewriteCond %{HTTP_HOST} ^(.+)\.dmtcenter\.com$ [NC]
RewriteCond %{REMOTE_ADDR} ^221\.132\.[0-6]{1,2}\. [OR]
RewriteCond %{REMOTE_ADDR} ^203\.162\.[0-5]{1,2}\. [OR]
RewriteCond %{REMOTE_ADDR} ^222\.252\.[0-5]{1,3}\. [OR]
RewriteRule ^(.*)$ http://%1.dmtcenter.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} !^www\.huyhoa\.biz$ [NC]
RewriteCond %{REMOTE_ADDR} !^221\.132\.[0-6]{1,2}\. [OR]
RewriteCond %{REMOTE_ADDR} !^203\.162\.[0-5]{1,2}\. [OR]
RewriteCond %{REMOTE_ADDR} !^222\.252\.[0-5]{1,3}\. [OR]
RewriteRule ^(.*)$ http://www.huyhoa.biz/$1 [R=301,L]
## KEt thuc ngan cam



I mean:

RewriteCond %{REMOTE_ADDR} ^221\.132\.[0-6]{1,2}\. [OR]


For 221.132.0.0 - 221.132.63.255


RewriteCond %{REMOTE_ADDR} ^203\.162\.[0-5]{1,2}\. [OR]


for: 203.162.0.0 - 203.162.54.255


And:

RewriteCond %{REMOTE_ADDR} ^222\.252\.[0-5]{1,3}\. [OR]



For: 222.252.0.0 - 222.252.255.255


But still dont work.
So, please give me some minute to help me, code this:
The list Ip is :
203.210.128.0 - 203.210.159.255
210.245.0.0 - 210.245.127.255
58.186.0.0 - 58.187.255.255
125.134.0.0 - 125.135.255.255
203.162.88.0 - 203.162.255.255
222.252.0.0 - 222.252.255.255
203.113.128.0 - 203.113.191.255
220.231.64.0 - 220.231.127.255
203.41.55.0 - 203.41.55.255
203.160.0.0 - 203.160.1.255
203.162.0.0 - 203.162.54.255
221.132.0.0 - 221.132.63.255



Please code how to enter http://huyhoa.biz, http://dmtcenter.com, http://www.huyhoa.biz/diendan/ and http://dmtcenter.com/news , it will alway check ip first, if ip in range of the list above, will redirect to http://news.dmtcenter.com
and if dont in range of the list above, will move to http://huyhoa.biz/diendan

Thanks for your help.
huyhoa
 
Posts: 35
Joined: Tue Nov 28, 2006 2:25 am

Postby richardk » Sun Jan 14, 2007 8:06 am

I still think you should just offer the person a link like i told you at doriat.com.

I think this should do it:
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^news\.dmtcenter\.com$ [NC]
# 58.186.0.0    - 58.187.255.255
# 125.134.0.0   - 125.135.255.255
# 222.252.0.0   - 222.252.255.255
# 203.41.55.0   - 203.41.55.255
# 203.160.0.0   - 203.160.1.255
RewriteCond %{REMOTE_ADDR} ^(0?58\.18[67]|125\.13[45]|222\.252|203\.0?41\.0?55|203\.160\.0*[01])\..+$ [OR]
# 203.162.0.0   - 203.162.54.255
# 203.162.88.0  - 203.162.255.255
RewriteCond %{REMOTE_ADDR} ^203\.162\.((0?[0-4]?[0-9]|5[0-4])|(0?8[89]|9[0-9]|[12][0-9]{2}))\..+$ [OR]
# 203.210.128.0 - 203.210.159.255
# 203.113.128.0 - 203.113.191.255
RewriteCond %{REMOTE_ADDR} ^203\.(210\.(1(2[89]|[3-5][0-9]))|113\.(1(2[89]|[3-8][0-9]|9[01]))\..+$ [OR]
# 210.245.0.0   - 210.245.127.255
RewriteCond %{REMOTE_ADDR} ^210\.245\.(0?[0-9]{1,2}|1[01][0-9]|12[0-7])\..+$ [OR]
# 220.231.64.0  - 220.231.127.255
RewriteCond %{REMOTE_ADDR} ^220\.231\.(0?6[4-9]|0?[7-9][0-9]|1[01][0-9]|12[0-7])\..+$ [OR]
# 221.132.0.0   - 221.132.63.255
RewriteCond %{REMOTE_ADDR} ^221\.132\.0*([0-9]|[0-5][0-9]|6[0-3])\..+$
RewriteRule ^(.*)$ http://news.dmtcenter.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST}%{REQUEST_URI} !^huyhoa\.biz/diendan(/.*)?$ [NC]
RewriteCond %{REMOTE_ADDR} !^(0?58\.18[67]|125\.13[45]|222\.252|203\.0?41\.0?55|203\.160\.0*[01])\..+$ [OR]
RewriteCond %{REMOTE_ADDR} !^203\.162\.((0?[0-4]?[0-9]|5[0-4])|(0?8[89]|9[0-9]|[12][0-9]{2}))\..+$ [OR]
RewriteCond %{REMOTE_ADDR} !^203\.(210\.(1(2[89]|[3-5][0-9]))|113\.(1(2[89]|[3-8][0-9]|9[01]))\..+$ [OR]
RewriteCond %{REMOTE_ADDR} !^210\.245\.(0?[0-9]{1,2}|1[01][0-9]|12[0-7])\..+$ [OR]
RewriteCond %{REMOTE_ADDR} !^220\.231\.(0?6[4-9]|0?[7-9][0-9]|1[01][0-9]|12[0-7])\..+$ [OR]
RewriteCond %{REMOTE_ADDR} !^221\.132\.0*([0-9]|[0-5][0-9]|6[0-3])\..+$
RewriteRule ^(.*)$ http://huyhoa.biz/diendan/$1 [R=301,L]


If you want any more IP address regular expressions you better learn: http://www.regular-expressions.info/tutorial.html.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

thank

Postby huyhoa » Mon Jan 22, 2007 10:30 pm

Thanks richardk, it 's me! but now i cant view doriat.com forum
phpBB : Critical Error

Could not obtain lastvisit data from user table

DEBUG MODE

SQL Error : 1146 Table 'doriatc_doriatf.dormod_users' doesn't exist

SELECT * FROM dormod_users WHERE user_id = -1

Line : 70
File : sessions.php

so, i find help here.
but when i use your code, the problem is ;
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@huyhoa.biz and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.


Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.


--------------------------------------------------------------------------------

Apache/1.3.36 Server at www.huyhoa.biz Port 80

see here : http://www.huyhoa.biz/diendan/
here is htacces code i use:
DirectoryIndex index.html index.htm portal.php index.php index.jsp
RewriteEngine on
ErrorDocument 404 http://huyhoa.biz/404.shtml
# Ngan cam IP Vietnam
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} !^news\.dmtcenter\.com$ [NC]
# 58.186.0.0 - 58.187.255.255
# 125.134.0.0 - 125.135.255.255
# 222.252.0.0 - 222.252.255.255
# 203.41.55.0 - 203.41.55.255
# 203.160.0.0 - 203.160.1.255
RewriteCond %{REMOTE_ADDR} ^(0?58\.18[67]|125\.13[45]|222\.252|203\.0?41\.0?55|203\.160\.0*[01])\..+$ [OR]
# 203.162.0.0 - 203.162.54.255
# 203.162.88.0 - 203.162.255.255
RewriteCond %{REMOTE_ADDR} ^203\.162\.((0?[0-4]?[0-9]|5[0-4])|(0?8[89]|9[0-9]|[12][0-9]{2}))\..+$ [OR]
# 203.210.128.0 - 203.210.159.255
# 203.113.128.0 - 203.113.191.255
RewriteCond %{REMOTE_ADDR} ^203\.(210\.(1(2[89]|[3-5][0-9]))|113\.(1(2[89]|[3-8][0-9]|9[01]))\..+$ [OR]
# 210.245.0.0 - 210.245.127.255
RewriteCond %{REMOTE_ADDR} ^210\.245\.(0?[0-9]{1,2}|1[01][0-9]|12[0-7])\..+$ [OR]
# 220.231.64.0 - 220.231.127.255
RewriteCond %{REMOTE_ADDR} ^220\.231\.(0?6[4-9]|0?[7-9][0-9]|1[01][0-9]|12[0-7])\..+$ [OR]
# 221.132.0.0 - 221.132.63.255
RewriteCond %{REMOTE_ADDR} ^221\.132\.0*([0-9]|[0-5][0-9]|6[0-3])\..+$
RewriteRule ^(.*)$ http://news.dmtcenter.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST}%{REQUEST_URI} !^huyhoa\.biz/diendan(/.*)?$ [NC]
RewriteCond %{REMOTE_ADDR} !^(0?58\.18[67]|125\.13[45]|222\.252|203\.0?41\.0?55|203\.160\.0*[01])\..+$ [OR]
RewriteCond %{REMOTE_ADDR} !^203\.162\.((0?[0-4]?[0-9]|5[0-4])|(0?8[89]|9[0-9]|[12][0-9]{2}))\..+$ [OR]
RewriteCond %{REMOTE_ADDR} !^203\.(210\.(1(2[89]|[3-5][0-9]))|113\.(1(2[89]|[3-8][0-9]|9[01]))\..+$ [OR]
RewriteCond %{REMOTE_ADDR} !^210\.245\.(0?[0-9]{1,2}|1[01][0-9]|12[0-7])\..+$ [OR]
RewriteCond %{REMOTE_ADDR} !^220\.231\.(0?6[4-9]|0?[7-9][0-9]|1[01][0-9]|12[0-7])\..+$ [OR]
RewriteCond %{REMOTE_ADDR} !^221\.132\.0*([0-9]|[0-5][0-9]|6[0-3])\..+$
RewriteRule ^(.*)$ http://huyhoa.biz/diendan/$1 [R=301,L]
########################################################################
RewriteCond %{HTTP_REFERER} !^http://backup.huyhoa.biz/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://backup.huyhoa.biz$ [NC]
RewriteCond %{HTTP_REFERER} !^http://fun.huyhoa.biz/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://fun.huyhoa.biz$ [NC]
RewriteCond %{HTTP_REFERER} !^http://huyhoa.biz/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://huyhoa.biz$ [NC]
RewriteCond %{HTTP_REFERER} !^http://music.huyhoa.biz/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://music.huyhoa.biz$ [NC]
RewriteCond %{HTTP_REFERER} !^http://search.huyhoa.biz/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://search.huyhoa.biz$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.huyhoa.biz/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.huyhoa.biz$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.phpbb.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.phpbb.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.phpbb2.de/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.phpbb2.de$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www2.huyhoa.biz/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www2.huyhoa.biz$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www3.huyhoa.biz/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www3.huyhoa.biz$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www4.huyhoa.biz/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www4.huyhoa.biz$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp|JPG|GIF|PNG|BMP|zip|rar|ZIP|RAR|exe|EXE)$ http://www.huyhoa.biz/thcb.gif [R,NC]

so i think your code may be has a small problem that you dont see, please check again for me. Thanks
huyhoa
 
Posts: 35
Joined: Tue Nov 28, 2006 2:25 am

Postby richardk » Tue Jan 23, 2007 9:42 am

Code: Select all
DirectoryIndex index.html index.htm portal.php index.php index.jsp
ErrorDocument 404 http://huyhoa.biz/404.shtml
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^news\.dmtcenter\.com$ [NC]
# 58.186.0.0 - 58.187.255.255
# 125.134.0.0 - 125.135.255.255
# 222.252.0.0 - 222.252.255.255
# 203.41.55.0 - 203.41.55.255
# 203.160.0.0 - 203.160.1.255
RewriteCond %{REMOTE_ADDR} ^(0?58\.18[67]|125\.13[45]|222\.252|203\.0?41\.0?55|203\.160\.0*[01])\..+$ [OR]
# 203.162.0.0 - 203.162.54.255
# 203.162.88.0 - 203.162.255.255
RewriteCond %{REMOTE_ADDR} ^203\.162\.((0?[0-4]?[0-9]|5[0-4])|(0?8[89]|9[0-9]|[12][0-9]{2}))\..+$ [OR]
# 203.210.128.0 - 203.210.159.255
# 203.113.128.0 - 203.113.191.255
RewriteCond %{REMOTE_ADDR} ^203\.(210\.(1(2[89]|[3-5][0-9]))|113\.(1(2[89]|[3-8][0-9]|9[01])))\..+$ [OR]
# 210.245.0.0 - 210.245.127.255
RewriteCond %{REMOTE_ADDR} ^210\.245\.(0?[0-9]{1,2}|1[01][0-9]|12[0-7])\..+$ [OR]
# 220.231.64.0 - 220.231.127.255
RewriteCond %{REMOTE_ADDR} ^220\.231\.(0?6[4-9]|0?[7-9][0-9]|1[01][0-9]|12[0-7])\..+$ [OR]
# 221.132.0.0 - 221.132.63.255
RewriteCond %{REMOTE_ADDR} ^221\.132\.0*([0-9]|[0-5][0-9]|6[0-3])\..+$
RewriteRule ^(.*)$ http://news.dmtcenter.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST}%{REQUEST_URI} !^huyhoa\.biz/diendan(/.*)?$ [NC]
RewriteCond %{REMOTE_ADDR} !^(0?58\.18[67]|125\.13[45]|222\.252|203\.0?41\.0?55|203\.160\.0*[01])\..+$ [OR]
RewriteCond %{REMOTE_ADDR} !^203\.162\.((0?[0-4]?[0-9]|5[0-4])|(0?8[89]|9[0-9]|[12][0-9]{2}))\..+$ [OR]
RewriteCond %{REMOTE_ADDR} !^203\.(210\.(1(2[89]|[3-5][0-9]))|113\.(1(2[89]|[3-8][0-9]|9[01])))\..+$ [OR]
RewriteCond %{REMOTE_ADDR} !^210\.245\.(0?[0-9]{1,2}|1[01][0-9]|12[0-7])\..+$ [OR]
RewriteCond %{REMOTE_ADDR} !^220\.231\.(0?6[4-9]|0?[7-9][0-9]|1[01][0-9]|12[0-7])\..+$ [OR]
RewriteCond %{REMOTE_ADDR} !^221\.132\.0*([0-9]|[0-5][0-9]|6[0-3])\..+$
RewriteRule ^(.*)$ http://huyhoa.biz/diendan/$1 [R=301,L]

RewriteCond %{HTTP_REFERER} !^http://((backup|search|music|fun|www[234]?)\.)?huyhoa.biz(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.phpbb.com(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.phpbb2.de(/.*)?$ [NC]
RewriteRule .*\.(jpe?g|gif|png|bmp|zip|rar|exe)$ http://www.huyhoa.biz/thcb.gif [R,NC,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Thanks

Postby huyhoa » Tue Jan 30, 2007 7:43 pm

Thanks richardk, work great,
but when use this http://huyhoa.biz/diendan it dont work, use http://huyhoa.biz/diendan/ its work, why?
huyhoa
 
Posts: 35
Joined: Tue Nov 28, 2006 2:25 am

Postby richardk » Wed Jan 31, 2007 6:20 am

Try replacing
Code: Select all
!^huyhoa\.biz/diendan(/.*)?$

with
Code: Select all
!^huyhoa\.biz/diendan/.*$
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 24 guests

cron