Reputation: 719
i'm not an expert in mod rewriting. i'm trying to rewrite multiple rules in .htaccess of my root directory which are as following:
RewriteEngine On
#HEADER REDIRECTION
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
#FINISH HEADER REDIRECTION
#PREVENT IF NOT USER_AGENT
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule .* - [F]
#FINISH PREVENT IF NOT USER_AGENT
#PREVENT UNEXPECTED USER_AGENT STRING
RewriteCond %{HTTP_USER_AGENT} ^Custo [OR]
RewriteCond %{HTTP_USER_AGENT} ^FlashGet [OR]
RewriteCond %{HTTP_USER_AGENT} ^GetRight [OR]
RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR]
RewriteCond %{HTTP_USER_AGENT} ^aHMView
RewriteRule .* - [F]
#FINISH PREVENT UNEXPECTED USER_AGENT STRING
#BYPASS STRANGERS
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{HTTP_REFERER} !^http://www.site.com [NC]
RewriteRule .* - [F]
#FINISH PYPASS STRANGERS
but the rules are causing internal server error 500
is there any mistake in it? if yes, how should i write it properly?
thanks,
Upvotes: 1
Views: 222
Reputation: 143966
Your rules are fin. They work for me in a blank htaccess file on a vanilla Apache 2.2 server. You probably don't have mod_rewrite loaded. Check that in your httpd.conf, the line that looks something like:
LoadModule rewrite_module modules/mod_rewrite.so
isn't commented out.
Upvotes: 1
Reputation: 1047
Try the "Basic .htaccess code syntax checker and validator" http://www.lyxx.com/freestuff/002.html or ".htaccess validator v1.06" http://shop.alterlinks.com/htaccess-validator/htaccess-validator.php
Upvotes: 1