Ask Question Forum:
Model Library:2025-02-08 Updated:A.I. model is online for auto reply question page
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by ddantes
at 2024-07-14 20:27:06
Point:250 Replies:9 POST_ID:828976USER_ID:11876
Topic:
Apache Web Server;;
The contact form on our website has been repeatedly spammed by visitors from certain countries. It also happens that we don't expect to do business with visitors from those countries. Can I use .htaccess to block a country's domain suffix? I understand that a large list of IP ranges can also be used, but I'd like to keep it simple. For example, would
"deny from .us" block visitors with the .us suffix?
"deny from .us" block visitors with the .us suffix?
Expert: duncanb7 replied at 2024-07-14 23:17:29
Thanks for your points
Have a nice day
Duncan
Have a nice day
Duncan
Accepted Solution
Expert: duncanb7 replied at 2024-07-14 23:11:07
250 points EXCELLENT
it may not work , otherwise why we will use RewriteRule/RewriteCond rule for a pattern search
Duncan
Duncan
Author: ddantes replied at 2024-07-14 23:06:01
Thank you for those details. Before closing this question, I'm still unclear about a couple of points. I am not seeking to block referrers or back links. I'm wanting to block web traffic from visitors within a specified country domain -- in this example, let' say ".us". So, returning to my original question, can I just use "deny from .us", or will that not work?
Expert: duncanb7 replied at 2024-07-14 23:01:30
if .htaccess approach is not fitting all of your need in future, you can
do it in php script that will let you more easier to program anything
or condition you want besides subdomain, Just redirect or forward all traffic to php script file path for IP cross-check or other check before user access your site.
Just for example php script reference only
do it in php script that will let you more easier to program anything
or condition you want besides subdomain, Just redirect or forward all traffic to php script file path for IP cross-check or other check before user access your site.
Just for example php script reference only
<?phpecho "<pre>REMOTE_ADRR = ".$_SERVER['REMOTE_ADDR']."</pre>";if ($_SERVER['REMOTE_ADDR']) { $t =$_SERVER['REMOTE_ADDR']; $o = preg_replace('/(\d+\.\d+\.\d+\.\d+)/e', 'get_host('\1')', $t); # $o = preg_replace('/(\d+\.\d+\.\d+\.\d+)/e', 'gethostbyaddr('\1')', $t); echo '<pre>DOMAIN = '.$o.'</pre>'; $str=".com"; echo "<pre.Target to block subdomain = ".$str."<pre>"; $pos=stripos($o,$str); if ($pos>0) { echo "<pre>Found $str subdomain at $t and it will block this IP address<pre>"; exit(); }}function get_host($ip){ $ptr= implode(".",array_reverse(explode(".",$ip))).".in-addr.arpa"; $host = dns_get_record($ptr,DNS_PTR); if ($host == null) return $ip; else return $host[0]['target'];}?><html><body><div style='color:blue'>No Domain is Block</div></body></html> 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:
Expert: duncanb7 replied at 2024-07-14 22:52:43
Proabably it will work. If not, try this
RewriteCond %{HTTP_REFERER} www.#*$!.us [NC,OR]
RewriteRule .* - [F]
There is a lot article in google if you search the word of "block subdomain .htaccess"
Duncan
RewriteCond %{HTTP_REFERER} www.#*$!.us [NC,OR]
RewriteRule .* - [F]
There is a lot article in google if you search the word of "block subdomain .htaccess"
Duncan
Author: ddantes replied at 2024-07-14 22:35:29
Thank you. Of course, I am using .us simply as an example, because I don't want to specify which country I plan to block. If I understood correctly, htaccess won't block visitors from a specific domain suffix, such as .us, simply by adding code: "deny from .us" and I must use a set of IP ranges. Is that correct? As an alternative to the "deny from" code, how about:
RewriteEngine On
RewriteCond %{HTTP_REFERER} .us [NC]
RewriteRule .* - [F]
RewriteEngine On
RewriteCond %{HTTP_REFERER} .us [NC]
RewriteRule .* - [F]
Expert: duncanb7 replied at 2024-07-14 22:15:24
Be reminded, when .us typing on client browser that wil be translated to number or IP by DNS server. so
you might need a tool or DNS tools to translate back to .us if you would like to keep a simple way
to solve the issue to block all .us address
Duncan
you might need a tool or DNS tools to translate back to .us if you would like to keep a simple way
to solve the issue to block all .us address
Duncan
Author: ddantes replied at 2024-07-14 20:45:58
Thanks for your comment. That site generates a huge table of IP ranges which block a specific country. I would prefer to keep the .htaccess code simple, and avoid using that method, if a simple ".us" would suffice. Will that work?
Expert: duncanb7 replied at 2024-07-14 20:35:25
Could you conside to use this method as follows in which it will
seach for all United'IP and do block in .htaccess file. It can also
select other countries.
http://www.ip2location.com/blockvisitorsbycountry.aspx
Duncan
seach for all United'IP and do block in .htaccess file. It can also
select other countries.
http://www.ip2location.com/blockvisitorsbycountry.aspx
Duncan