.htaccess:RewriteRule:无法编译正则表达式

时间:2014-07-10 21:26:57

标签: regex apache .htaccess mod-rewrite

将网站从apache 2.2移至2.4.9并在日志文件中出现此错误:

/public_html/.htaccess: RewriteRule: cannot compile regular expression '^encyclopedia-terms([0-9]*)-([a-zA-Z0-9_-?\xa7?a2?\xa8U\xbe???\xab?\xac?\x86?\xad?\xae?\xaf?\xb0?\xb1?\xb2???\xb3?\xb4?\xb5?\xb6?\xb7?\xb8?\xb9??U?U\x82U\x83?\xa9?\xafU\x84U\x85U\x86U\x88U\x87U\x8cU?]*).html',

浏览器出错:
服务器遇到内部错误或配置错误,无法完成您的请求。 请与webmaster @ domain的服务器管理员联系,告知他们此错误发生的时间以及您在此错误发生之前执行的操作。 服务器错误日志中可能提供了有关此错误的更多信息。 此外,尝试使用ErrorDocument处理请求时遇到500内部服务器错误错误。

#####################################  Start htaccess sec code
<Files ~ "^\.ht">
Order allow,deny
Deny from all
</Files>
<Files config.php>
order allow,deny
deny from all
</Files>
#####################################  end htaccess sec code
<IFModule mod_rewrite.c>
RewriteEngine on
#####################################  Start Set Your Path
RewriteBase /
#####################################  End Set Your Path
#####################################  Start Injection/xss/Agent Blocking
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} ^.*(;|<|>|�|�|\)|%0A|%0D|%22|%27|%3C|%3E|).*(/\*|union|concat).* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Anarchie [OR]
RewriteCond %{HTTP_USER_AGENT} ^ASPSeek [OR]
RewriteCond %{HTTP_USER_AGENT} ^attach [OR]
RewriteCond %{HTTP_USER_AGENT} ^autoemailspider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Xaldon\ WebSpider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Xenu [OR]
RewriteCond %{HTTP_USER_AGENT} ^Zeus.*Webster [OR]
RewriteCond %{HTTP_USER_AGENT} ^Zeus
RewriteRule ^.* - [F,L]
#####################################  End Injection/xss Blocking
RewriteRule ^index.html index.php
#Articles
RewriteRule ^article-([0-9]*)-([a-z]*)-([0-9]*)-([0-9]*).html modules.php?name=News&file=article-seo&sid=$1&mode=$2&order=$3&thold=$4
RewriteRule ^article-([0-9-]*)-([a-z]*)-([0-9]*)-([0-9]*).html([0-9#]*) modules.php?name=News&file=article-seo&thold=$1&mode=$2&order=$3&sid=$4$5
RewriteRule ^article-topic([0-9]*)-page([0-9]*).html modules.php?name=News&new_topic=$1&page=$2
RewriteRule ^article-category([0-9]*)-page([0-9]*).html modules.php?name=News&file=categories&op=newindex&catid=$1&page=$2
RewriteRule ^article-category-([0-9]*).html modules.php?name=News&file=categories&op=newindex&catid=$1
RewriteRule ^article-print-([0-9]*).html modules.php?name=News&file=print&sid=$1
RewriteRule ^article-friend-([0-9]*).html modules.php?name=News&file=friend&op=FriendSend&sid=$1
RewriteRule ^article-page-([0-9]*).html modules.php?name=News&page=$1
RewriteRule ^article([1-9][0-9]*).* modules.php?name=News&file=article-seo&sid=$1 [L]
RewriteRule ^([0-9]*)-([a-z]*) modules.php?name=News&file=article-seo&sid=$1  
RewriteRule ^([0-9]*)/([a-z]*) modules.php?name=News&file=article-seo&sid=$1  
#RewriteRule ^/([^/]*)\([1-9][0-9]*)  modules.php?name=News&file=article-seo&sid=$1  [L]
RewriteRule ^article-topic-([0-9]*).html modules.php?name=News&new_topic=$1 
RewriteRule ^t-([1-9][0-9]*)-([^/]*).html modules.php?name=News&new_topic=$1
RewriteRule ^allnews.html modules.php?name=News&file=allindex
RewriteRule ^news.html modules.php?name=News

RewriteRule ^tags/([a-zA-Z0-9_.-اآبپتثجچحخدذرزژسشصضطظعغÙقكکگلمنوهیي]*)/page/([0-9]*)/ modules.php\?name=News&file=tags&tags=$1&page=$2
RewriteRule ^tags/([a-zA-Z0-9_.-اآبپتثجچحخدذرزژسشصضطظعغÙقكکگلمنوهیي]*)/page/([0-9]*) modules.php\?name=News&file=tags&tags=$1&page=$2
RewriteRule ^tags/([a-zA-Z0-9_.-اآبپتثجچحخدذرزژسشصضطظعغÙقكکگلمنوهیي]*)/ modules.php?name=News&file=tags&tags=$1
RewriteRule ^tags/([a-zA-Z0-9_.-اآبپتثجچحخدذرزژسشصضطظعغÙقكکگلمنوهیي]*) modules.php?name=News&file=tags&tags=$1


#Products
RewriteRule ^Products-([0-9]*)-([a-z]*)-([0-9]*)-([0-9]*).html modules.php?name=Products&file=product&sid=$1&mode=$2&order=$3&thold=$4
RewriteRule ^Products-([0-9-]*)-([a-z]*)-([0-9]*)-([0-9]*).html([0-9#]*) modules.php?name=Products&file=product&thold=$1&mode=$2&order=$3&sid=$4$5
RewriteRule ^Products-topic([0-9]*)-page([0-9]*).html modules.php?name=Products&new_topic=$1&page=$2
RewriteRule ^Products-category([0-9]*)-page([0-9]*).html modules.php?name=Products&file=categories&op=newindex&catid=$1&page=$2
RewriteRule ^Products-category-([0-9]*).html modules.php?name=Products&file=categories&op=newindex&catid=$1
RewriteRule ^Products-print-([0-9]*).html modules.php?name=Products&file=print&sid=$1
RewriteRule ^Products-friend-([0-9]*).html modules.php?name=Products&file=friend&op=FriendSend&sid=$1
RewriteRule ^Products-page-([0-9]*).html modules.php?name=Products&page=$1
RewriteRule ^Products-([1-9][0-9]*).* modules.php?name=Products&file=product&sid=$1 [L]
RewriteRule ^Products-([0-9]*)-([a-z]*) modules.php?name=Products&file=product&sid=$1  
RewriteRule ^Products/([0-9]*)/([a-z]*) modules.php?name=Products&file=product&sid=$1  
#RewriteRule ^/([^/]*)\([1-9][0-9]*)  modules.php?name=Products&file=product&sid=$1  [L]
RewriteRule ^Products-topic-([0-9]*).html modules.php?name=Products&new_topic=$1 
RewriteRule ^Products-t-([1-9][0-9]*)-([^/]*).html modules.php?name=Products&new_topic=$1
RewriteRule ^allProducts.html modules.php?name=Products&file=allindex
RewriteRule ^Products.html modules.php?name=Products
RewriteRule ^Good-([0-9]*).html modules.php?name=cart&op=addgood&gdn=$1
RewriteRule ^Products-tags-([a-zA-Z0-9_.-اآبپتثجچحخدذرزژسشصضطظعغÙقكکگلمنوهیي]*).html modules.php?name=Products&file=tags&tags=$1
RewriteRule ^Products-tags-([a-zA-Z0-9_.-اآبپتثجچحخدذرزژسشصضطظعغÙقكکگلمنوهیي]*)-([0-9]*).html modules.php?name=Products&file=tags&tags=$1&page=$2
RewriteRule ^Products/tags/([a-zA-Z0-9_.-اآبپتثجچحخدذرزژسشصضطظعغÙقكکگلمنوهیي]*) modules.php?name=Products&file=tags&tags=$1
RewriteRule ^Products/tags/([a-zA-Z0-9_.-اآبپتثجچحخدذرزژسشصضطظعغÙقكکگلمنوهیي]*)/([0-9]*) modules.php?name=Products&file=tags&tags=$1&page=$2



#AvantGo
RewriteRule ^avantgo-print-([0-9]*).html modules.php?name=AvantGo&file=print&sid=$1
RewriteRule ^avantgo.html modules.php?name=AvantGo

#Content
RewriteRule ^content-([0-9]*)-page([0-9]*).html modules.php?name=Content&file=content&op=showpage&pid=$1&page=$2
RewriteRule ^content-cat-([0-9]*).html modules.php?name=Content&file=topic&op=list_pages_categories&cid=$1
RewriteRule ^content-([0-9]*).html modules.php?name=Content&file=content&op=showpage&pid=$1
RewriteRule ^content-([0-9]*)-ok.html modules.php?name=Content&file=content&op=showpage&pid=$1&ok=1
RewriteRule ^content-topics.html modules.php?name=Content&file=topic
RewriteRule ^content-topic-([0-9]*).html modules.php?name=Content&file=index&new_cat=$1
RewriteRule ^content-tags-([a-zA-Z0-9_.-اآبپتثجچحخدذرزژسشصضطظعغÙقكکگلمنوهیي]*).html modules.php?name=Content&file=tags&tags=$1
RewriteRule ^content-tags-([a-zA-Z0-9_.-اآبپتثجچحخدذرزژسشصضطظعغÙقكکگلمنوهیي]*)-([0-9]*).html modules.php?name=Content&file=tags&tags=$1&page=$2
RewriteRule ^content/tags/([a-zA-Z0-9_.-اآبپتثجچحخدذرزژسشصضطظعغÙقكکگلمنوهیي]*) modules.php?name=Content&file=tags&tags=$1
RewriteRule ^content/tags/([a-zA-Z0-9_.-اآبپتثجچحخدذرزژسشصضطظعغÙقكکگلمنوهیي]*)/([0-9]*) modules.php?name=Content&file=tags&tags=$1&page=$2
RewriteRule ^content.html modules.php?name=Content

#Downloads
RewriteRule ^downloadview-(comments|details|editorial)-([0-9]*)-([[:punct:]/:\-\'{}()._&a-zA-Z0-9+=]*).html modules.php?name=Downloads&d_op=viewdownload$1&lid=$2&ttitle=$3
RewriteRule ^download-mod-([0-9]*).html modules.php?name=Downloads&d_op=modifydownloadrequest&lid=$1
RewriteRule ^download-broken-([0-9]*).html modules.php?name=Downloads&d_op=brokendownload&lid=$1
RewriteRule ^download-shownew-([0-9]*).html modules.php?name=Downloads&d_op=NewDownloads&newdownloadshowdays=$1
RewriteRule ^download-seldate-([a-zA-Z0-9+]*).html modules.php?name=Downloads&d_op=NewDownloadsDate&selectdate=$1
RewriteRule ^download-file-([0-9]*).html modules.php?name=Downloads&d_op=getit&lid=$1
RewriteRule ^ratedownload-([0-9]*)-([[:punct:]/:\-\'{}()._&a-zA-Z0-9+=]*).html modules.php?name=Downloads&d_op=ratedownload&lid=$1&ttitle=$2
RewriteRule ^ratedownload-([0-9]*).html modules.php?name=Downloads&d_op=ratedownload&lid=$1
RewriteRule ^download-(TopRated|MostPopular)-([0-9]*)-(num|percent).html modules.php?name=Downloads&d_op=$1&ratenum=$2&ratetype=$3
RewriteRule ^downloads-(AddDownload|NewDownloads|MostPopular|TopRated).html modules.php?name=Downloads&d_op=$1
RewriteRule ^download([0-9]*)-orderby([a-zA-Z0-9+]*).html modules.php?name=Downloads&d_op=viewdownload&cid=$1&orderby=$2
RewriteRule ^download([0-9]*)-([0-9]*)-([a-zA-Z0-9+]*)-([0-9]*).html modules.php?name=Downloads&d_op=viewdownload&cid=$1&min=$2&orderby=$3&show=$4
RewriteRule ^download-search-([[:punct:]/:\-\'{}()._&a-zA-Z0-9+=]*)-([0-9]*)-([a-zA-Z0-9+]*)-([0-9]*).html modules.php?name=Downloads&d_op=search&query=$1&min=$2&orderby=$3&show=$4
RewriteRule ^download-search-([[:punct:]/:\-\'{}()._&a-zA-Z0-9+=]*)-([a-zA-Z0-9+]*).html modules.php?name=Downloads&d_op=search&query=$1&orderby=$2
RewriteRule ^download-search-([[:punct:]/:\-\'{}()._&a-zA-Z0-9+=]*).html modules.php?name=Downloads&d_op=search&query=$1
RewriteRule ^download-outside-([0-9]*).html modules.php?name=Downloads&d_op=outsidedownloadsetup&lid=$1
RewriteRule ^downloads-cat([0-9]*).html modules.php?name=Downloads&d_op=viewdownload&cid=$1
RewriteRule ^downloads.html modules.php?name=Downloads

#Encyclopedia
RewriteRule ^encyclopedia-([0-9]*)-page([0-9]*)-([a-zA-Z0-9_-]*).html modules.php?name=Encyclopedia&op=content&tid=$1&page=$2&query=$3
RewriteRule ^encyclopedia-([0-9]*)-page([0-9]*).html modules.php?name=Encyclopedia&op=content&tid=$1&page=$2
RewriteRule ^encyclopedia-([0-9]*)-([a-zA-Z0-9_-]*).html modules.php?name=Encyclopedia&op=content&tid=$1&query=$2
RewriteRule ^encyclopedia-([0-9]*).html modules.php?name=Encyclopedia&op=content&tid=$1
RewriteRule ^encyclopedia-list-([0-9]*).html modules.php?name=Encyclopedia&op=list_content&eid=$1
RewriteRule ^encyclopedia-terms([0-9]*)-([a-zA-Z0-9_-اآبپتثجچحخدذرزژسشصضطظعغÙقكکگلمنوهیي]*).html modules.php?name=Encyclopedia&op=terms&eid=$1&ltr=$2
RewriteRule ^encyclopedia-search-([a-zA-Z0-9_-]*).html modules.php?name=Encyclopedia&file=search&query=$1
RewriteRule ^encyclopedia-search.html modules.php?name=Encyclopedia&file=search
RewriteRule ^encyclopedia.html modules.php?name=Encyclopedia

#Feedback
RewriteRule ^feedback.html modules.php?name=Feedback

#FAQ
RewriteRule ^faq.html modules.php?name=FAQ
RewriteRule ^faq-([0-9]*)-([a-zA-Z0-9\+\&\-\/%[:punct:]\.\;]*).html modules.php?name=FAQ&myfaq=yes&id_cat=$1&categories=$2

#Forums
RewriteRule ^ftopicp-([0-9]*).html /Forum/viewtopic.php?p=$1 [R=301,L]
RewriteRule ^ftopict-([0-9]*).html /Forum/viewtopic.php?t=$1 [R=301,L]
RewriteRule ^modules.php?name=Forums&file=viewtopic&p=([0-9]*) /Forum/viewtopic.php?p=$1 [R=301,L]
RewriteRule ^modules.php?name=Forums&file=viewtopic&t=([0-9]*) /Forum/viewtopic.php?t=$1 [R=301,L]

#Journal
RewriteRule ^journal-search-([a-zA-Z0-9]*).html modules.php?name=Journal&file=searchbywhat=aid&exact=1&forwhat=$1
RewriteRule ^journal(search|delete|commentkill)-(bywhat|jid|onwhat)([a-zA-Z0-9]*)-(forwhat|ref)([a-zA-Z0-9]*).html modules.php?name=Journal&file=$1&$2=$3&$4=$5
RewriteRule ^journal-search-([0-9]*)-([a-zA-Z0-9_-]*).html modules.php?name=Journal&file=search&bywhat=$1&forwhat=$2
RewriteRule ^journal-([a-zA-Z0-9+]*)-(jid|onwhat|disp|op|disp)-([a-zA-Z0-9+]*).html modules.php?name=Journal&file=$1&$2=$3
RewriteRule ^journal-edit.html modules.php?name=Journal&file=edit
RewriteRule ^journal(file|op)-([a-zA-Z0-9]*).html modules.php?name=Journal&$1=$2
RewriteRule ^journal.html modules.php?name=Journal

#Members List
RewriteRule ^members.html modules.php?name=Members_List

#Private Messages
RewriteRule ^messages-post-([0-9]*).html modules.php?name=Private_Messages&file=index&mode=post&u=$1
RewriteRule ^messages-post-([0-9]*).html modules.php?name=Private_Messages&mode=post&u=$1
RewriteRule ^messages-new.html modules.php?name=Private_Messages&file=index&mode=post
RewriteRule ^messages-(sentbox|inbox|savebox|outbox).html modules.php?name=Private_Messages&file=index&folder=$1
RewriteRule ^messages.html modules.php?name=Private_Messages

#Recommend Us
RewriteRule ^recommend.html modules.php?name=Recommend_Us

#Reviews
RewriteRule ^reviews-new.html modules.php?name=Reviews&rop=write_review
RewriteRule ^reviews-preview.html modules.php?name=Reviews&rop=preview_review
RewriteRule ^reviews-([0-9]*)-page([0-9]*).html modules.php?name=Reviews&rop=showcontent&id=$1&page=$2
RewriteRule ^reviews-([0-9]*).html modules.php?name=Reviews&rop=showcontent&id=$1
RewriteRule ^reviews-comment-([0-9]*)-([[:punct:]?/:\-\'{}()._&a-zA-Z0-9+=\%]*).* modules.php?name=Reviews&rop=postcomment&id=$1&title=$2
RewriteRule ^reviews-([0-9]*)-delete.html modules.php?name=Reviews&rop=del_review&id_del=$1
RewriteRule ^reviews-([0-9]*)-edit.html modules.php?name=Reviews&rop=mod_review&id=$1
RewriteRule ^reviews-([0-9]*)-delcomment-([0-9]*).html modules.php?name=Reviews&rop=del_comment&cid=$1&id=$2
RewriteRule ^reviews-([a-zA-Z0-9]*)-orderby-([a-z]*)-([a-zA-Z]*).html modules.php?name=Reviews&rop=$1&field=$2&order=$3
RewriteRule ^reviews-sortby-([a-zA-Z0-9]*).html modules.php?name=Reviews&rop=$1
RewriteRule ^reviews.html modules.php?name=Reviews

#Search
RewriteRule ^search.html modules.php?name=Search

#Statistics
RewriteRule ^stats-([0-9]*)-([0-9]*)-([0-9]*).html modules.php?name=Statistics&op=DailyStats&year=$1&month=$2&date=$3
RewriteRule ^stats-([0-9]*)-([0-9]*).html modules.php?name=Statistics&op=MonthlyStats&year=$1&month=$2
RewriteRule ^stats-([0-9]*).html modules.php?name=Statistics&op=YearlyStats&year=$1
RewriteRule ^advstats.html modules.php?name=Statistics&op=Stats
RewriteRule ^stats.html modules.php?name=Statistics

#Stories Archive
RewriteRule ^archive-([0-9]*)-([0-9]*)-([a-zA-Z]*).* modules.php?name=Stories_Archive&sa=show_month&year=$1&month=$2&month_l=$3
RewriteRule ^archive-showall.html modules.php?name=Stories_Archive&sa=show_all
RewriteRule ^archive.html modules.php?name=Stories_Archive
php_flag display_errors on
php_flag display_startup_errors on    

1 个答案:

答案 0 :(得分:0)

您的正则表达式无法编译,因为连字符-被解释为字符范围标记。将其移动到字符范围的顶部。我们也可以做一些调整,虽然很难知道确切的意图。试试这个:

^encyclopedia-terms([0-9]*)-([-\w\xa2\xa7\xa8\xa9\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xbe\x82\x83\x84\x85\x86\x88\x87\x8c]*).html
  • 移动了-
  • 使用\w代替字母,数字和下划线
  • 删除了无用的?
  • 重组了字符

这可以缩短为:

^encyclopedia-terms([0-9]*)-([-\w\xa2§-©«-¹\xbe\x82-\x88\x8c]*).html