Hello, I will PayPal $10 to the first person who provides the correct solution. (I will insert your code into my .htaccess file to confirm that it works.) I am on a Linux server. It's a shared server, but I do have a dedicated IP. In my .htaccess file, I need to block the following two user agents EXACTLY: ----------------------------- Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1 Opera/9.02 (Windows NT 5.1; U; ru) ----------------------------- I don't want to block innocent visitors by making the blocks too general. Therefore, I need to block each exact, entire string (including all the stuff inside the parentheses). Thank you
Try this: # good bye RewriteEngine on RewriteCond %{HTTP_USER_AGENT} ^Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1 [OR] RewriteCond %{HTTP_USER_AGENT} ^Opera/9.02 (Windows NT 5.1; U; ru) RewriteRule ^(.*)$ http://www.google.com Code (markup):
That won't work. Please try: RewriteEngine on RewriteCond %{HTTP_USER_AGENT} ^Opera/9.02\ \(Windows\ NT\ 5.1;\ U;\ ru\)$ [OR] RewriteCond %{HTTP_USER_AGENT} ^Mozilla/5.0\ \(Windows;\ U;\ Windows\ NT\ 5.1;\ ru;\ rv:1.8.1.1\)\ Gecko/20061204\ Firefox/2.0.0.1$ RewriteRule ^.*$ deny.html [L] Code (markup): Jay
Jayshah, Don't you have to escape the periods? I'm not sure, but I think I read that somewhere online.
This works: RewriteEngine on RewriteCond %{HTTP_USER_AGENT} ^Opera/9.02\ \(Windows\ NT\ 5.1;\ U;\ ru\)$ [OR] RewriteCond %{HTTP_USER_AGENT} ^Mozilla/5.0\ \(Windows;\ U;\ Windows\ NT\ 5.1;\ ru;\ rv:1.8.1.1\)\ Gecko/20061204\ Firefox/2.0.0.1$ [OR] RewriteCond %{HTTP_USER_AGENT} ^Mozilla/4.0\ \(compatible;\ MSIE\ 7.0;\ Windows\ NT\ 6.0;\ WOW64;\ SLCC1;\ .NET\ CLR\ 2.0.50727;\ .NET\ CLR\ 3.0.04506;\ .NET\ CLR\ 1.1.4322\)$ RewriteRule ^.*$ deny.html [L] (I added the last one just to test - this works on my server and blocks like it's supposed to.) If you put these in and it still does not work, it's likely that there is something else in your file causing the 500 error, not these lines specifically. Are you copying and pasting them in? If so, it could be a problem with line feeds that you are pasting in..... Maybe try just typing them in instead.
Try this : <IfModule mod_rewrite.c> RewriteCond %{HTTP_USER_AGENT} ^Opera/9.02 (Windows NT 5.1; U; ru) [OR] RewriteCond %{HTTP_USER_AGENT} ^Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1 RewriteRule ^.* - [F,L] </IfModule> Code (markup): If u still geting 500 error. then u shold do this: 1. Edit the file /etc/sysconfig/apache2 as root: 1. search for APACHE_MODULES, you should find a line like this APACHE_MODULES="suexec access actions alias auth auth_dbm autoindex cgi dir env expires include log_config mime negotiation setenvif userdir ssl php4" 2. Add rewrite to the content in the list between the " 3. Save the changes and quit 2. run SuSEconfig to update the apache configuration files 3. run /etc/init.d/apache2 restart to restart the Apache server Code (markup):
A friend of a friend, who happens to be a database admin for a big company, actually came to my house and fixed the problem because I was in a panic. We went out to celebrate afterwards. Just got back. Mivent, I just tested your code by putting it in place of my friend's code. It does appear to work. I appreciate your effort! Therefore, I would like to send you something via PayPal, anyway. Sicario, thank you for your efforts, as well.
why would you want to block user agents? Blocking opera and firefox blocks a large portion of internet users. If you want to block a specific user, use their IP Useragents are not user specific, they're the way a browser identifies itself to a website... ie all Firefox 3.0.1 browsers have the SAME useragent