#1  
Old 29th December 2008, 08:59
Boon-Dog-Danny Boon-Dog-Danny is offline
Member
 
Join Date: Jul 2006
Posts: 97
Thanks: 11
Thanked 1 Time in 1 Post
Default .htaccess and RewriteEngine On

I'm really confused about the htaccess file I have read a ton of tutorials and forums yet I'm still not able to get this working right,

RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^-$ [OR]
RewriteCond %{HTTP_USER_AGENT} ^_$ [OR]
RewriteRule .* - [F]

that cause server errors..


anyone know how to add this?
__________________
Debian(rocks) + Ispconfig 3.0.3


Boon-Inc.com Great Video
Boon-File.com Create flash text
Boon-Host.com Get great FREE games here
Boon-Dog.com glitter text makers,music and more
Reply With Quote
Sponsored Links
  #2  
Old 29th December 2008, 09:31
Antennipasi Antennipasi is offline
ISPConfig Developer
 
Join Date: Dec 2008
Location: Finland
Posts: 67
Thanks: 6
Thanked 13 Times in 12 Posts
Default

Quote:
Originally Posted by Boon-Dog-Danny View Post
anyone know how to add this?
maybe. first you should say what (and why?) you are trying to do, and post here how your .htaccess looks now.
apache-errors does not hurt eirher...
Reply With Quote
  #3  
Old 29th December 2008, 16:10
Boon-Dog-Danny Boon-Dog-Danny is offline
Member
 
Join Date: Jul 2006
Posts: 97
Thanks: 11
Thanked 1 Time in 1 Post
Default

im enabling the rewrite in the htaccess file
do I have to enclose the conditions in a tag?


<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^-$ [OR]
RewriteCond %{HTTP_USER_AGENT} ^_$ [OR]
RewriteRule .* - [F]
</ifModule>
__________________
Debian(rocks) + Ispconfig 3.0.3


Boon-Inc.com Great Video
Boon-File.com Create flash text
Boon-Host.com Get great FREE games here
Boon-Dog.com glitter text makers,music and more
Reply With Quote
  #4  
Old 29th December 2008, 18:03
Antennipasi Antennipasi is offline
ISPConfig Developer
 
Join Date: Dec 2008
Location: Finland
Posts: 67
Thanks: 6
Thanked 13 Times in 12 Posts
Default

Quote:
Originally Posted by Boon-Dog-Danny View Post
anyone know how to add this?
Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^-$ [OR]
RewriteCond %{HTTP_USER_AGENT} ^_$
RewriteRule ^.* - [F,L]
</ifModule>
this should do the trick. make sure that mod_rewrite is actually enabled. above code will return "Error 403 Forbidden" for matching user agents.
looks like you are trying to block robots, right?
Reply With Quote
  #5  
Old 30th December 2008, 00:19
Boon-Dog-Danny Boon-Dog-Danny is offline
Member
 
Join Date: Jul 2006
Posts: 97
Thanks: 11
Thanked 1 Time in 1 Post
Default

those actually block a DoS attack, I went ahead and placed it in my /etc/apache2

<Directory /var/www/*/web>
Options +Includes -Indexes
AllowOverride All
AllowOverride Indexes AuthConfig Limit FileInfo
Order allow,deny
Allow from all
<Files ~ "^\.ht">
Deny from all
</Files>
<files ~ "^\.st">
Order allow,deny
Deny from all
Satisfy All
</files>
<Files images>
deny from all
</Files>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^$ [OR]
RewriteCond %{HTTP_USER_AGENT} ^-$ [OR]
RewriteCond %{HTTP_USER_AGENT} ^_$ [OR]
RewriteCond %{HTTP_USER_AGENT} ^.*Morfeus.*$ [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*revolt.*$ [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*Toata.*$ [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^libwww-perl [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^libwww-perl/[0-9].[0-9]* [NC,OR]
RewriteCond %{THE_REQUEST} (\?act\=) [NC,OR]
RewriteCond %{THE_REQUEST} (sql_login) [NC,OR]
RewriteCond %{THE_REQUEST} (basepath) [NC,OR]
RewriteCond %{THE_REQUEST} (libpath) [NC,OR]
RewriteCond %{THE_REQUEST} (absolute_path) [NC,OR]
RewriteCond %{THE_REQUEST} (vwar_root) [NC,OR]
RewriteCond %{THE_REQUEST} (includedir) [NC,OR]
RewriteCond %{THE_REQUEST} (file=http:\/\/) [NC,OR]
RewriteCond %{THE_REQUEST} (name=http:\/\/) [NC,OR]
RewriteCond %{THE_REQUEST} (phpbb_root_path) [NC,OR]
RewriteCond %{REMOTE_ADDR} ^63\.148\.99\.2(2[4-9]|[34][0-9]|5[0-5])$ [OR]
RewriteCond %{REMOTE_ADDR} ^63\.226\.3[34]\. [OR]
RewriteCond %{REMOTE_ADDR} ^63\.212\.171\.161$ [OR]
RewriteCond %{REMOTE_ADDR} ^65\.118\.41\.(19[2-9]|2[01][0-9]|22[0-3])$ [OR]
RewriteCond %{REMOTE_ADDR} ^12\.148\.196\.(12[8-9]|1[3-9][0-9]|2[0-4][0-9]|25[0-5])$ [OR]
RewriteCond %{REMOTE_ADDR} ^12\.148\.209\.(19[2-9]|2[0-4][0-9]|25[0-5])$ [OR]
RewriteCond %{REMOTE_ADDR} ^65\.102\.12\.2(2[4-9]|3[01])$ [OR]
RewriteCond %{REMOTE_ADDR} ^65\.102\.17\.(3[2-9]|[4-6][0-9]|7[01]|8[89]|9[0-5]|10[4-9]|11[01])$ [OR]
RewriteCond %{REMOTE_ADDR} ^65\.102\.23\.1(5[2-9]|6[0-7])$ [OR]
RewriteCond %{REMOTE_ADDR} ^128\.242\.197\.101$ [OR]
RewriteCond %{REMOTE_ADDR} ^64\.140\.49\.6([6-9])$ [OR]
RewriteCond %{REMOTE_ADDR} ^66\.51\.199\.244$ [OR]
RewriteRule .* - [F,L]
</IfModule>
</Directory>

seems to be working ok.
__________________
Debian(rocks) + Ispconfig 3.0.3


Boon-Inc.com Great Video
Boon-File.com Create flash text
Boon-Host.com Get great FREE games here
Boon-Dog.com glitter text makers,music and more
Reply With Quote
  #6  
Old 30th December 2008, 00:31
Boon-Dog-Danny Boon-Dog-Danny is offline
Member
 
Join Date: Jul 2006
Posts: 97
Thanks: 11
Thanked 1 Time in 1 Post
Wink

Quote:
Originally Posted by Antennipasi View Post
Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^-$ [OR]
RewriteCond %{HTTP_USER_AGENT} ^_$
RewriteRule ^.* - [F,L]
</ifModule>
this should do the trick. make sure that mod_rewrite is actually enabled. above code will return "Error 403 Forbidden" for matching user agents.
looks like you are trying to block robots, right?
wanted to add in case someone was reading ..I dont think the above code would work, although it would not throw an error either..
RewriteCond %{HTTP_USER_AGENT} ^_$ <---no [OR] ..rewrite stops here never to go to the next line to fail and last .. no error but no result..
RewriteRule ^.* - [F,L]
</ifModule>

I could be wrong but I have been reading a lot about how it works http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html and I dont think you leave off the last or next condition.. but thanks
__________________
Debian(rocks) + Ispconfig 3.0.3


Boon-Inc.com Great Video
Boon-File.com Create flash text
Boon-Host.com Get great FREE games here
Boon-Dog.com glitter text makers,music and more

Last edited by Boon-Dog-Danny; 30th December 2008 at 00:36.
Reply With Quote
  #7  
Old 30th December 2008, 12:26
Antennipasi Antennipasi is offline
ISPConfig Developer
 
Join Date: Dec 2008
Location: Finland
Posts: 67
Thanks: 6
Thanked 13 Times in 12 Posts
Default

Quote:
Originally Posted by Boon-Dog-Danny View Post
wanted to add in case someone was reading ..I dont think the above code would work, although it would not throw an error either..
RewriteCond %{HTTP_USER_AGENT} ^_$ <---no [OR] ..rewrite stops here never to go to the next line to fail and last .. no error but no result..
RewriteRule ^.* - [F,L]
</ifModule>

I could be wrong but I have been reading a lot about how it works http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html and I dont think you leave off the last or next condition.. but thanks
i think you should read that page again. on link you posted search "or next condition". there should not be [OR]- or [AND]-statement in last RewriteCond-line. if you put it on code i sended, it will give error for any useragent, because there is no RewriteConditions anymore. in examplecode mod_rewrite keeps reading until [L] is terminating it in RewriteRule.
Reply With Quote
  #8  
Old 31st December 2008, 03:45
Boon-Dog-Danny Boon-Dog-Danny is offline
Member
 
Join Date: Jul 2006
Posts: 97
Thanks: 11
Thanked 1 Time in 1 Post
Default re

well thats why I said i did not think.. I did re-read the page I see the photo shows nothing, i wonder if [NC] would still be needed.. being host3 could be upper or lowercase http://FOO.COM.. follow? I have other How htaccess works sites that show the or tags all the way as well.. I'm going to try it without it, and if I have trouble I'll just readd it.

thanks by the way
__________________
Debian(rocks) + Ispconfig 3.0.3


Boon-Inc.com Great Video
Boon-File.com Create flash text
Boon-Host.com Get great FREE games here
Boon-Dog.com glitter text makers,music and more
Reply With Quote
  #9  
Old 31st December 2008, 09:28
Antennipasi Antennipasi is offline
ISPConfig Developer
 
Join Date: Dec 2008
Location: Finland
Posts: 67
Thanks: 6
Thanked 13 Times in 12 Posts
 
Default

Quote:
Originally Posted by Boon-Dog-Danny View Post
well thats why I said i did not think.. I did re-read the page I see the photo shows nothing, i wonder if [NC] would still be needed.. being host3 could be upper or lowercase http://FOO.COM.. follow? I have other How htaccess works sites that show the or tags all the way as well.. I'm going to try it without it, and if I have trouble I'll just readd it.

thanks by the way
yes i follow [NC] could be there, it does no say anything about next condition. [OR] and [AND] are logical operators and logically does not work if there is nothing to operate with. keep on reading and trying, thats what we all have to do.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
wordpress MU and ISPconfig .htaccess isues palkat General 4 18th October 2006 11:57
ISPConfig and .htaccess ionut89 Feature Requests 1 17th October 2006 17:45
.htaccess login challenge broken with mod_rewrite ozonblue Installation/Configuration 2 13th September 2006 10:09
RewriteEngine - Debian Sarge - Apache2 DerLobo Installation/Configuration 7 5th July 2006 10:37
.htaccess question Ovidiu Installation/Configuration 3 13th March 2006 23:30


All times are GMT +2. The time now is 02:03.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.