Apache .htaccess-RewriteCond:错误的标志分隔符

Apache .htaccess-RewriteCond:错误的标志分隔符,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,我正在使用.htaccess阻止对我的站点的一些错误请求。在我的本地服务器(XAMPP)上一切正常,但当我将其上载到主机(共享)时,我遇到了以下错误:RewriteCond:bad flag delimiters 这是我的.htaccess中的代码 ServerSignature Off Options -Indexes RewriteEngine On RewriteCond %{REQUEST_METHOD} ^(HEAD|TRACE|DELETE|TRACK|DEBUG) [NC] R

我正在使用.htaccess阻止对我的站点的一些错误请求。在我的本地服务器(XAMPP)上一切正常,但当我将其上载到主机(共享)时,我遇到了以下错误:
RewriteCond:bad flag delimiters

这是我的.htaccess中的代码

ServerSignature Off
Options -Indexes

RewriteEngine On

RewriteCond %{REQUEST_METHOD} ^(HEAD|TRACE|DELETE|TRACK|DEBUG) [NC]
RewriteRule ^(.*)$ - [F,L]

RewriteCond %{HTTP_USER_AGENT} (libwww-perl|wget|python|nikto|curl|scan|java|winhttp|clsh ttp|loader) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} (<|>|'|%0A|%0D|%27|%3C|%3E|%00) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} (;|<|>|'|"|\)|\(|%0A|%0D|%22|%27|%28|%3C|%3E|%00). *(libwww-perl|wget|python|nikto|curl|scan|java|winhttp|HTTr ack|clshttp|archiver|loader|email|harvest|extract| grab|miner) [NC,OR]

RewriteCond %{THE_REQUEST} \/\*\ HTTP/ [NC,OR]
RewriteCond %{THE_REQUEST} etc/passwd [NC,OR]
RewriteCond %{THE_REQUEST} cgi-bin [NC,OR]
RewriteCond %{THE_REQUEST} (%0A|%0D) [NC,OR]
RewriteCond %{THE_REQUEST} \?\ HTTP/ [NC,OR]

RewriteCond %{QUERY_STRING} ^(.*);(.*)$ [NC,OR]
RewriteCond %{QUERY_STRING} ^(.*)\"|\(|\)(.*)$ [NC,OR]
RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=http:// [OR]
RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=(\.\.//?)+ [OR]
RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=/([a-z0-9_.]//?)$ [NC,OR]
RewriteCond %{QUERY_STRING} \=PHP[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} [NC,OR]
RewriteCond %{QUERY_STRING} (\.\./|\.\.) [OR]
RewriteCond %{QUERY_STRING} ftp\: [NC,OR]
RewriteCond %{QUERY_STRING} http\: [NC,OR]
RewriteCond %{QUERY_STRING} https\: [NC,OR]
RewriteCond %{QUERY_STRING} \=\|w\| [NC,OR]
RewriteCond %{QUERY_STRING} ^(.*)/self/(.*)$ [NC,OR]
RewriteCond %{QUERY_STRING} ^(.*)cPath=http://(.*)$ [NC,OR]
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} (\<|%3C).*iframe.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^i]*i)+frame.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [NC,OR]
RewriteCond %{QUERY_STRING} base64_(en|de)code[^(]*\([^)]*\) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} ^.*(\[|\]|\(|\)|<|>).* [NC,OR]
RewriteCond %{QUERY_STRING} (NULL|OUTFILE|LOAD_FILE) [OR]
RewriteCond %{QUERY_STRING} (\./|\../|\.../)+(motd|etc|bin) [NC,OR]
RewriteCond %{QUERY_STRING} (localhost|loopback|127\.0\.0\.1) [NC,OR]
RewriteCond %{QUERY_STRING} (<|>|'|%0A|%0D|%27|%3C|%3E|%00) [NC,OR]
RewriteCond %{QUERY_STRING} concat[^\(]*\( [NC,OR]
RewriteCond %{QUERY_STRING} union([^s]*s)+elect [NC,OR]
RewriteCond %{QUERY_STRING} union([^a]*a)+ll([^s]*s)+elect [NC,OR]
RewriteCond %{QUERY_STRING} (;|<|>|'|"|\)|%0A|%0D|%22|%27|%3C|%3E|%00).*(/\*|union|select|insert|drop|delete|update|cast|cre ate|char|convert|alter|declare|order|script|set|md 5|benchmark|encode) [NC,OR]
RewriteCond %{QUERY_STRING} (sp_executesql) [NC]
RewriteRule ^(.*)$ - [F,L]

<FilesMatch "^(install\.php|setup\.php|wp-config\.php|config\.php|configuration\.php|php\.in i|php5\.ini|bb-config\.php|db.php)">
Order allow,deny
Deny from all
</FilesMatch>

Options -ExecCGI
AddHandler cgi-script .php .pl .py .jsp .asp .htm .shtml .sh .cgi
AddType text/plain .pl .cgi .php
<FilesMatch "\.(php|pl|py|jsp|asp|htm|shtml|sh|cgi)$">
ForceType text/plain
</FilesMatch>
ServerSignature关闭
选项-索引
重新启动发动机
RewriteCond%{REQUEST_METHOD}^(HEAD | TRACE | DELETE | TRACK | DEBUG)[NC]
重写规则^(.*)$-[F,L]
重写cond%{HTTP|u USER|u AGENT}(libwww perl | wget | python | nikto | curl | scan | java | winhttp | clsh ttp | loader)[NC,OR]
重写cond%{HTTP|u USER|u AGENT}(|'|%0A |%0D |%27 |%3C |%3E |%00)[NC,或]
(12)除了除了除了除了除了除了目前的美国用户(U U U U U用户)和美国联邦政府代理方之外,再重写第二次全国各州各州各州各州各州的一个(12)日当天当天当天当天当天当天{{{{HTTP用户(U U U U U U U U U U U用户)代理方}((124;124;124;124;124;124;|124;124;|| ||除了除了除了除了除了除了除了除了除了除了除了除了除了除了除了除了除了除了除了除了上述上述上述上述各州各州各州各州各州各州各州??124??124;;;;124;124;;;|本本州州州各州各州各州各州各州各州各州各州各州各州各州各州各州各州各州各州各州各州各州各州各州各州各州各州各州的一124??124;124?124;124?|本本本|;||
RewriteCond%{u请求}\/\*\HTTP/[NC,或]
重写cond%{THE_REQUEST}etc/passwd[NC,OR]
RewriteCond%{THE_REQUEST}cgi bin[NC,OR]
重写条件%{U请求}(%0A |%0D)[NC,或]
RewriteCond%{THE_REQUEST}\?\HTTP/[NC,或]
重写条件%{QUERY_STRING}^(.*);(.*)$[NC,或]
重写条件%{QUERY\u STRING}^(.*)\“|\(|\)(.*)$[NC,或]
RewriteCond%{QUERY_STRING}[a-zA-Z0-9\]=http://[OR]
重写cond%{QUERY\u STRING}[a-zA-Z0-9\]=(\.\.\./?)+[OR]
重写cond%{QUERY_STRING}[a-zA-Z0-9\]=/([a-Z0-9\]//?)$[NC,或]
重写cond%{QUERY_STRING}\=PHP[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}[NC,或]
重写条件%{QUERY\u STRING}(\.\./\.\.\.\.\)[或]
RewriteCond%{QUERY_STRING}ftp\:[NC,或]
RewriteCond%{QUERY_STRING}http\:[NC,或]
RewriteCond%{QUERY_STRING}https\:[NC,或]
RewriteCond%{QUERY\u STRING}\=\\\\ w\\\\[NC,或]
重写条件%{QUERY_STRING}^(.*)/self/(.*)$[NC,或]
RewriteCond%{QUERY_STRING}^(.*)cPath=http://(.*)$[NC,或]
重写条件%{QUERY\u STRING}(\\\\%3E)[NC,或]
重写cond%{QUERY_STRING}(|%3E)[NC,或]
重写条件%{QUERY\u STRING}(\\\\%3E)[NC,或]
重写cond%{QUERY_STRING}(|%3E)[NC,或]
重写COND%{QUERY_STRING}base64_encode.\(.*\)[NC或]
重写cond%{QUERY_STRING}base64(en|de)代码[^(]*\([^)]*\)[NC,或]
重写条件%{QUERY\u STRING}全局(|\[|\%[0-9A-Z]{0,2})[或]
重写条件%{QUERY\u STRING}{u请求(|\[|\%[0-9A-Z]{0,2})[或]
重写cond%{QUERY\u STRING}^.*(\[\\]\\(\\)\.*).[NC,或]
RewriteCond%{QUERY_STRING}(NULL | OUTFILE | LOAD_FILE)[或]
重写cond%{QUERY|u STRING}(\./\../\\…/)+(motd|etc|bin)[NC,或]
重写cond%{QUERY_STRING}(localhost | loopback | 127\.0\.0\.1)[NC,或]
重写cond%{QUERY_STRING}(|'|%0A |%0D |%27 |%3C |%3E |%00)[NC,或]
重写cond%{QUERY\u STRING}concat[^\(]*\([NC,或]
重写cond%{QUERY_STRING}并集([^s]*s)+选择[NC,或]
重写cond%{QUERY_STRING}并集([^a]*a)+ll([^s]*s)+选择[NC,或]
重写cond%{QUERY|u STRING}(;| |“|\)%0A |%0D |%22 |%27 |%3C |%3E |%00)。*(/\*| union | select | insert | drop | delete | update cast | cre ate | char convert | convert | alter | declare | order | md
重写cond%{QUERY_STRING}(sp_executesql)[NC]
重写规则^(.*)$-[F,L]
命令允许,拒绝
全盘否定
选项-执行CGI
AddHandler cgi script.php.pl.py.jsp.asp.htm.shtml.sh.cgi
AddType text/plain.pl.cgi.php
强制类型文本/纯文本
我已经删除了尾随空格和注释。仍然会出现此错误。

正则表达式中有一些(可能)不需要的空格,这对我有用:

ServerSignature Off
Options -Indexes

RewriteEngine On

RewriteCond %{REQUEST_METHOD} ^(HEAD|TRACE|DELETE|TRACK|DEBUG) [NC]
RewriteRule ^(.*)$ - [F,L]

RewriteCond %{HTTP_USER_AGENT} (libwww-perl|wget|python|nikto|curl|scan|java|winhttp|clshttp|loader) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} (<|>|'|%0A|%0D|%27|%3C|%3E|%00) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} (;|<|>|'|"|\)|\(|%0A|%0D|%22|%27|%28|%3C|%3E|%00).*(libwww-perl|wget|python|nikto|curl|scan|java|winhttp|HTTrack|clshttp|archiver|loader|email|harvest|extract|grab|miner) [NC,OR]

RewriteCond %{THE_REQUEST} \/\*\ HTTP/ [NC,OR]
RewriteCond %{THE_REQUEST} etc/passwd [NC,OR]
RewriteCond %{THE_REQUEST} cgi-bin [NC,OR]
RewriteCond %{THE_REQUEST} (%0A|%0D) [NC,OR]
RewriteCond %{THE_REQUEST} \?\ HTTP/ [NC,OR]

RewriteCond %{QUERY_STRING} ^(.*);(.*)$ [NC,OR]
RewriteCond %{QUERY_STRING} ^(.*)\"|\(|\)(.*)$ [NC,OR]
RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=http:// [OR]
RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=(\.\.//?)+ [OR]
RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=/([a-z0-9_.]//?)$ [NC,OR]
RewriteCond %{QUERY_STRING} \=PHP[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} [NC,OR]
RewriteCond %{QUERY_STRING} (\.\./|\.\.) [OR]
RewriteCond %{QUERY_STRING} ftp\: [NC,OR]
RewriteCond %{QUERY_STRING} http\: [NC,OR]
RewriteCond %{QUERY_STRING} https\: [NC,OR]
RewriteCond %{QUERY_STRING} \=\|w\| [NC,OR]
RewriteCond %{QUERY_STRING} ^(.*)/self/(.*)$ [NC,OR]
RewriteCond %{QUERY_STRING} ^(.*)cPath=http://(.*)$ [NC,OR]
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} (\<|%3C).*iframe.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^i]*i)+frame.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [NC,OR]
RewriteCond %{QUERY_STRING} base64_(en|de)code[^(]*\([^)]*\) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} ^.*(\[|\]|\(|\)|<|>).* [NC,OR]
RewriteCond %{QUERY_STRING} (NULL|OUTFILE|LOAD_FILE) [OR]
RewriteCond %{QUERY_STRING} (\./|\../|\.../)+(motd|etc|bin) [NC,OR]
RewriteCond %{QUERY_STRING} (localhost|loopback|127\.0\.0\.1) [NC,OR]
RewriteCond %{QUERY_STRING} (<|>|'|%0A|%0D|%27|%3C|%3E|%00) [NC,OR]
RewriteCond %{QUERY_STRING} concat[^\(]*\( [NC,OR]
RewriteCond %{QUERY_STRING} union([^s]*s)+elect [NC,OR]
RewriteCond %{QUERY_STRING} union([^a]*a)+ll([^s]*s)+elect [NC,OR]
RewriteCond %{QUERY_STRING} (;|<|>|'|"|\)|%0A|%0D|%22|%27|%3C|%3E|%00).*(/\*|union|select|insert|drop|delete|update|cast|create|char|convert|alter|declare|order|script|set|md5|benchmark|encode) [NC,OR]
RewriteCond %{QUERY_STRING} (sp_executesql) [NC]
RewriteRule ^(.*)$ - [F,L]

<FilesMatch "^(install\.php|setup\.php|wp-config\.php|config\.php|configuration\.php|php\.ini|php5\.ini|bb-config\.php|db.php)">
Order allow,deny
Deny from all
</FilesMatch>

Options -ExecCGI
AddHandler cgi-script .php .pl .py .jsp .asp .htm .shtml .sh .cgi
AddType text/plain .pl .cgi .php
<FilesMatch "\.(php|pl|py|jsp|asp|htm|shtml|sh|cgi)$">
ForceType text/plain
</FilesMatch>
ServerSignature关闭
选项-索引
重新启动发动机
RewriteCond%{REQUEST_METHOD}^(HEAD | TRACE | DELETE | TRACK | DEBUG)[NC]
重写规则^(.*)$-[F,L]
重写cond%{HTTP|u USER|u AGENT}(libwww perl | wget | python | nikto | curl | scan | java | winhttp | clshttp | loader)[NC,OR]
重写cond%{HTTP|u USER|u AGENT}(|'|%0A |%0D |%27 |%3C |%3E |%00)[NC,或]
重写cond%{HTTP|u USER|u AGENT}(;| |'|“|\)|\(|%0A |%0D |%22 |%27 |%28 |%3C |%3E |%00)。*(libwww perl | wget | python | nikto | curl | scan | scan | java | winhttp | HTTrack | clshttp | 3E | rack | rack | NC |提取加载程序或抓取|
RewriteCond%{u请求}\/\*\HTTP/[NC,或]
重写cond%{THE_REQUEST}etc/passwd[NC,OR]
RewriteCond%{THE_REQUEST}cgi bin[NC,OR]
重写条件%{U请求}(%0A |%0D)[NC,或]
RewriteCond%{THE_REQUEST}\?\HTTP/[NC,或]
重写条件%{QUERY_STRING}^(.*);(.*)$[NC,或]
重写条件%{QUERY\u STRING}^(.*)\“|\(|\)(.*)$[NC,或]
RewriteCond%{QUERY_STRING}[a-zA-Z0-9\]=http://[OR]
重写cond%{QUERY\u STRING}[a-zA-Z0-9\]=(\.\.\./?)+[OR]
重写cond%{QUERY_STRING}[a-zA-Z0-9\]=/([a-Z0-9\]//?)$[NC,或]
重写cond%{QUERY_STRING}\=PHP[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}[NC,或]
重写条件%{QUERY\u STRING}(\.\./\.\.\.\.\)[或]
RewriteCond%{QUERY_STRING}ftp\:[NC,或]
RewriteCond%{QUERY_STRING}http\:[NC,或]
RewriteCond%{QUERY_STRING}https\:[NC,或]
RewriteCond%{QUERY\u STRING}\=\\\\ w\\\\[NC,或]
重写条件%{QUERY_STRING}^(.*)/self/(.*)$[NC,或]
RewriteCond%{QUERY_STRING}^(.*)cPath=http://(.*)$[NC,或]
重写条件%{QUERY\u STRING}(\\\\%3E)[NC,或]
重写cond%{QUERY_STRING}(|%3E)[NC,或]
重写条件%{QUERY\u STRING}(\\\\%3E)[NC,或]
重写cond%{QUERY_STRING}(|%3E)[NC,或]
重写COND%{QUERY_STRING}base64_encode.\(.*\)[NC或]
重写cond%{QUERY_STRING}base64(en|de)代码[^(]*\([^)]*\)[NC,或]
重写条件%{QUERY\u STRING}全局(|\[|\%[0-9A-Z]{0,2})[或]
重写条件%{QUERY\u STRING}{u请求(|\[|\%[0-9A-Z]{0,2})[或]
重写cond%{QUERY\u STRING}^.*(\[\\]\\(\\)\.*).[NC,或]
RewriteCond%{QUERY_STRING}(NULL | OUTFILE | LOAD_FILE)[或]
重写cond%{QUERY|u STRING}(\./\../\\…/)+(motd|etc|bin)[NC,或]
重写cond%{QUERY_STRING}(localhost | loopback | 127\.0\.0\.1)[NC,或]
重写cond%{QUERY_STRING}(|'|%0A |%0D |%27 |%3C |%3E |%00)[NC,或]
重写cond%{QUERY\u STRING}concat[^\(]*\([NC,或]
重写cond%{QUERY_STRING}并集([^s]*s)+选择[NC,或]
重写cond%{QUERY_STRING}并集([^a]*a)+ll([^s]*s)+选择[NC,或]
重写cond%{QUERY|u STRING}(;| |'|“|\)%0A |%0D |%22 |%27 |%3C |%3E |%00)。*(/\*| union | select | insert | drop | delete | update cast | cast | create | char convert | convert | convert | alter | alter | declare | order | script set |脚本集|或编码)
重写cond%{QUERY_STRING}(sp_executesql)[NC]
重写
RewriteCond %{QUERY_STRING} (;|<|>|'|"|\)|%0A|%0D|%22|%27|%3C|%3E|%00).*(/\*|union|select|insert|drop|delete|update|cast|cre ate|char|convert|alter|declare|order|script|set|md 5|benchmark|encode) [NC,OR]