Recently my website has been getting a lot of suspicious visits from weird countries like Congo, Saudia Arabia, Pakistan, India, Vietnam, Brazil. My website caters only to people in one city in USA, there is no reason why anyone from other cities or countries should be visiting it. They come from weird search engines. So for example instead of coming from google.com or yahoo.com they come from sexygirlsearch.info
I am getting hundreds of these per day.
Every day, the search engine changes. but it is consistent throughout the day. For example yesterday it was all from alosearch.info
today it's all from sexygirlsearch.info
I believe these are human visitors because one of them actually filled out a contact form that has a human test.
so what's the solution to this? I have been doing a lot of reading and it appears that there is no reliable way to block countries.
can I block specific search engines? How can I block anyone coming from sexygirlsearch.info
You can block specific HTTP referers in .htaccess. For example:
RewriteEngine On
RewriteCond %{HTTP_REFERER} sexygirlssearch\.info [OR]
RewriteCond %{HTTP_REFERER} alosearch\.info [OR]
RewriteCond %{HTTP_REFERER} anotheronetoblock\.com
RewriteRule ^ - [F]
If the HTTP_REFERER contains either sexygirlssearch.info, alosearch.info or anotheronetoblock.com anywhere in the string then your default 403 Forbidden will be served.
Note that the last condition does not use the OR flag.
This should go at the top of your .htaccess file.
Related
I think I have achieved the holy grail of generic wildcard subdomain redirection after going around in circles for a whole day battling "too many redirects" errors. It seems to work with any domain and subdomain, the only part you need to specify is a list of possible valid suffixes eg .com|.com.au|.co.uk etc. This code will take *yourdomain.suffix for any domain and turn it into http://www.yourdomain.suffix, but only for valid subdomains that could actually exist. You can have as many sequences of anything.anything-anything.anything-anything-anything.anything. before yourdomain.com as you want, it will all get turned into www. Now it seems to work perfectly, but I don't trust this sadistic language of regex one bit. I have absolutely no way of knowing if this code is valid, if it will cause server problems or fail under some important circumstances. Can anyone help bug-test or refine it?
Here it is:
RewriteCond %{HTTP_HOST} ^([a-zA-Z0-9]+[a-zA-Z0-9\-]*[a-zA-Z0-9]+[\.]{1}|[a-zA-Z0-9]+[\.]{1})*([a-zA-Z0-9]+[a-zA-Z0-9\-]*[a-zA-Z0-9]+|[a-zA-Z0-9]+)\.(com|com[\.]{1}au)?$ [NC]
RewriteCond %{HTTP_HOST} !^www\.([a-zA-Z0-9]+[a-zA-Z0-9\-]*[a-zA-Z0-9]+|[a-zA-Z0-9]+)\.(com|com[\.]{1}au)?$ [NC]
RewriteRule .? http://www.%2.%3%{REQUEST_URI} [R=302,NC,L]
Note: The reason it's so long is because I'm trying to account for the possibility of dashes in the main domain or subdomain parts. So anything-anything.youdomain.com. But I read that with domain names you're not allowed to have dashes without at least one alphanumerical character between the dash and any period. So www.anything-.yourdomain.com or www.-anything.yourdomain.com are both invalid and must be rejected. If I didn't have to consider this, the regex for the first 2 lines would be way simpler: it could just start with:
RewriteCond %{HTTP_HOST} ^([a-zA-Z0-9\-]+[\.]{1})*([a-zA-Z0-9\-]+)\.(com|com[\.]{1}au)?$
I want to completely block requests for urls in this format:
/cat/pathfinder/pathfinder-accessories/?add-to-cart=27368
or
/cat/pathfinder/?add-to-cart=27368
I tried to do this via HTaccess :
RewriteRule ^(.*)cat$^(.*)?add-to-cart=$^(.*)$ - [F]
But that doesn't match. Can you see why not?
I have other, simpler rewriterules in the same .htaccess file that are working.
Context:
I have an online shop site being pounded by automated requests to 'add to cart'. The shop has thousands of products, so the impact of so many simultaneous requests on memory & processor is horrible. (The shop is Wordpress with Woocommerce, if that matters)
I changed things so that there are no longer pages of 20 products where the bot can hit 'add to cart' simultaneously on all of them any more, but they are still hitting them, so clearly they have a list. I've been unable to block the requests by IP, as they are coming via Cloudflare from many locations.
Query string is not matched using RewriteRule.
You can use this rule instead:
RewriteCond %{THE_REQUEST} /cat/[^?]*\?add-to-cart=\d+ [NC]
RewriteRule ^ - [F]
For the past 4 weeks (yes you read right, 4 weeks) I 've been trying to redirect my website to a new domain.
Here's what I want to do:
Redirect the ROOT of my website from ukmotorhomehirerental to leisurerentalsdirect.com
Without redirecting all the subfolders. ie. if I click on a link in google to one of our minor pages, I want to land on that page on the new domain without being redirected to the index page. It worth mentioning that I do want to also redirect the minor pages on a page to page basis.
I'm doing it like this (this works perfect)...
RedirectRule ^/pages/contentPage.asp\?QN=94 http://www.leisurerentalsdirect.com/pages/contentPage.asp?QN=94 [I,R=301]
However this This is were the problem lies...
RedirectRule ^/ http://www.leisurerentalsdirect.com [I,R=301]
I know the above implies to the browser that all traffic requesting ukmotorhomehirerental will be forwarded to leisurerentalsdirect
I think I need some sought of condition applying, but I just cannot understand how to do this, can anybody help?
You don't actually say what the problem is, but I think you want www.ukmotorhomehirerental.com to go www.leisurerentalsdirect.com and www.ukmotorhomehirerental.com/somepage to go to www.leisurerentalsdirect.com/somepage, right?
If so, you should only need a single redirect rule:
RewriteCond %{HTTP_HOST} ^www\.ukmotorhomehirerental\.com/? [NC]
RewriteRule ^(.*)$ http://www.leisurerentalsdirect.com/$1 [L,R=301]
This will simply redirect any page on ukmotorhomhirerental.com to the same page (or root, if none) on leisurerentalsdirect.com.
I am trying to redirect access to one part of my site before a certain date. I am using ISAPI_Rewrite 3 on IIS 6 but I believe ISAPI_Rewrite is compatible with mod_rewrite syntax. Imagine I wanted to redirect pages to a certain address before the 1st April 2012. I have found examples where people use something like this:
RewriteCond %{TIME_YEAR}%{TIME_MON}%{TIME_DAY} <20120401
The problem I have is that the server variables for TIME_MON and TIME_DAY appear to be returning single digits (e.g. 1 rather than 01).
So for the 1st May %{TIME_YEAR}%{TIME_MON}%{TIME_DAY} returns 201251 rather than 20120501.
201251 is less than 20120401 BUT the first of May is AFTER the first of April.
How do I get around this problem?
Looking at Time based rewrites - how to handle two seperate years? I have realised that I may be coming at this from the wrong direction.
I think something like the following could work for me:
RewriteCond %{REQUEST_URI} ^/Someplace/(.*)\.aspx$
RewriteCond %{TIME_YEAR} ^2012
RewriteCond %{TIME_MON} <4
RewriteRule ^(.*)$ /Someplace/systemdown.html [R=301,L]
I'm owner of http://myisfahan.com. I have an article management system there that developed by myself.
Recently I changed article links from myisfahan.com/articles/isfahan_articleXXX.html to myisfahan.com/XXX_[article subject].html in newer version. Many of my articles had high ranking on Google (in Persian language).
Because I didn't know redirect older links to newer one I only wrote 2 instruction only in the .htaccess:
RewriteRule ^([0-9]+)_([^/\.]+).html$ maghalat.php?id=$1
RewriteRule ^articles/isfahan_articles([0-9]+).html$ maghalat.php?id=$1
After this major change Google.com dropped many of my page rankings and recently I have only 20% of normal site visitors.
My questions are:
Does this changes caused this drop of ranking, because in fact now I have 2 links for every content .
I fetch subject text by PHP and generate XXX_[article subject].html, how can I write a rewrite syntax that redirect isfahan_articlesXXX.html to XXX_[article subject].html file when XXX is article's ID in .htaccess file?
You should have 301 redirected your old links to your new links, after creating your new links.
If you did not or are duplicating links to the same content, this would indeed hurt your rankings.
UPDATE
Looks like you already have the RewriteRules in place that you need. Just add the following flags (note the 301 redirect for the old links) and over time it should (over time) rebuild your page rank.
RewriteRule ^([0-9]+)_([^/\.]+).html$ maghalat.php?id=$1 [L]
RewriteRule ^articles/isfahan_articles([0-9]+).html$ maghalat.php?id=$1 [R=301,L]