Articles of 正则expression式

了解IIS 8.0使用正则expression式将https的入站规则重写为httpredirect

我设法使用这个答案为我的网站configuration一个重写规则: <rule name="Redirect from non www" stopProcessing="true"> <match url=".*" /> <conditions> <add input="{HTTP_HOST}" pattern="^example.com$" /> </conditions> <action type="Redirect" url="https://www.example.com/{R:0}" redirectType="Permanent" /> </rule> <!– this is the rule I am interested in –> <rule name="Redirect from non https" stopProcessing="true"> <match url=".*" /> <conditions> <add input="{HTTPS}" pattern="^OFF$" /> <add input="{HTTP_HOST}" pattern="^www.example.com$" /> </conditions> <action type="Redirect" url="https://www.example.com/{R:0}" redirectType="Permanent" […]

如何search匹配正则expression式模式并在特定date范围内注册的域名?

如何search匹配在特定date范围内注册的正则expression式模式的域名? 到目前为止,我已经find一个网站,可以让你用正则expression式来search域名,但它没有选项来指定注册或更新date。 ARIN有一个支持域名search的RDAP客户端,但没有办法指定date范围来缩小它们,显然不支持正则expression式。 某些组织以高成本提供了一定范围内的所有域名注册活动的大规模转储,但似乎是因为这些信息都在各个WHOIS数据库中,所以应该有一种在WHOIS中使用正则expression式来获取所有WHOIS匹配某些date信息和其域名符合特定正则expression式模式的logging。 不过,我似乎无法find任何这样的服务。 当然,谷歌search与“域名search”相关的任何内容都只是提供了数以千计的链接来注册一个域名。 我能find的最接近的东西就是search,但是它只能追溯到30天,我正在寻找更远的地方,可能长达120天。

基于文件和目录名称的Apache访问限制

我想configurationhttpd.conf拒绝符合以下任一项的文件: 以开头的目录. 或_ 一个以文件开始的文件. 或_ ,但不匹配__\w+__\.\w+ 例如: /_private/anything -> deny (rule 1) /_private/__init__.py -> deny (rule 1) /_private/_private.txt -> deny (rule 1+2) /public/_private.txt -> deny (rule 2) /public/__private.txt -> deny (rule 2) /public/__public__.txt -> allow 我一直在使用<Directory ~ "…">和<Files ~ "…">以及RewriteRule ,但一直没有得到正确的工作。 build议非常感谢! 谢谢! 更新:针对CK: <Directory "/var/www/html"> Order allow,deny Allow from all </Directory> 更新2:有没有人知道为什么这个指令匹配和拒绝像/_test.php ,当它显然不是一个“目录”的url? (我删除了除.htaccess之外的所有<Files>部分。) […]

如何让sdiff忽略*字符?

我确信这是一个简单的方法,但我无法弄清楚。 我有两个文件: file1: You are in a maze of twisty little passages, all alike file2: You are in a maze of twisty little* passages, all alike 我想对这些文件执行sdiff ,但我想忽略*字符。 我该怎么做呢?

具有查询string的图像的mod_rewrite规则

我是一个mod_rewrite新手和正则expression式noob,但这是我想要做的: 我有一个脚本 ,将在飞行中重新调整图像的大小。 我希望能够采取任何图像文件path,添加一个查询string,并自动发送到脚本进行处理。 所以像这样: from: http://mysite.com/images/logo.jpg?w=100&h=50 to: http://mysite.com/images/thumbs/phpThumb.php?src=logo.jpg&w=100&h=50 当然,如果没有指定查询string,它应该指向原始文件。 使用/ images中的.htaccess文件,我已经得到了这个。 但它根本不起作用。 或者至多,它打破了我所有的网站图像: <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{QUERY_STRING} ^.* RewriteRule ([^\s]+(\.(?i)(jpg|png|gif|bmp))$) /thumbs/phpThumb.php?src=$1 [L,QSA] </IfModule>

根据QUERY_STRING拒绝访问该网站

我的网站“受到攻击”:来自许多不同IP的漫游器正在填充垃圾内容的表单。 IP地址不能过滤,它们总是不同的,所以我想按照QUERY_STRING进行过滤,来匹配这样一个URI: www.site.com/search?field1=spamword&field2=another_spamword 规则 : rewritecond %{QUERY_STRING} ^(.*)spamword(.*)$ rewriterule .* – [F,L] 正则expression式看起来是正确的,但规则永远不会执行。 任何想法发生了什么? 谢谢。

请求超过了10的限制

我的日志是满的 [Tue Jan 11 10:20:45 2011] [error] [client 99.162.115.123] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: https://www.domain.com/vehicles/Chevrolet/Uplander/2006 问题是当我启用LogLevel debug我们得到巨大的错误日志,因为我们所有的stream量是SSL。 从我可以告诉该文件不再logging这些错误,或者它是如此埋在SSL日志中,我无法find它们。 这是我的.htaccess Options -indexes RewriteEngine On RewriteRule ^battery/([^/]+)$ /browser/product?sku=BATTERY+$1&type=battery RewriteRule ^vehicles/([^/]+)/([^/]+)/([^/]+)/product([0-9]+)$ /browser/index.php?make=$1&model=$2&id=$3&%{QUERY_STRING} [L,NC] RewriteRule […]

ForceType / SetHandler代码 – 为什么这个工作?

我试过这个代码,虽然它出于某种原因工作,是不是有错误呢? 我不知道什么是最好的方法来纠正这一点,但在这里是… <Files .+*^$[]()> ForceType application/x-httpd-php SetHandler application/x-httpd-php </Files> 不知道为什么它的作品; 这是一个正则expression式错误? 这是否意味着我可以用PHP代码和图像等扩展文件,它会工作得很好,或者是否有替代代码? (牢记这是从一个PHP脚本论坛…)

基本的Apache日志正则expression式

我正努力使用仅仅使用HTTP返回代码来匹配Apache日志上的Fail2Ban的failregex 。 我使用的日志格式如下,在这个例子中是显示“200”的字段。 只要其他领域(以这种格式)可以是其他任何东西,那就只是我感兴趣的领域。 66-121-89-14.domain.com – – [14/Apr/2011:14:47:05 +0100] "GET /city/index.html HTTP/1.1" 200 2577 "http://www.domain.com/referrer/" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16" 我想我需要这样的东西。 failregex = ^(?P<host>\S*).*("-" "-"| 502 | 500 | 417 | 416 | 415 | 414 | 413 | 412 | 405 | 403 | 一个正则expression式爱好者可以帮忙吗?

我可以使用什么正则expression式来标识nginx日志中的无效文件请求?

我需要帮助为fail2banconfiguration正则expression式。 我使用我的networking服务器主要用于简单的播客文件托pipe,但我看到很多无效的请求在日志中的PHP,ASP和PL文件。 我想configurationfail2ban在日志中查找这些types的无效文件请求。 有一点,我有以下正则expression式string设置为Apache: [[] client []](没有这样的文件或目录脚本未find或无法统计):/\S*(php|mysql|.asp|.exe|.pl) [[] client []] script'/\S*(.php|.asp|.exe|.pl)\S*'not found or unable to stat * $ 这显然不适用于nginx日志。 这是一个不良文件请求的摘录(我改变了path和IP): 2011/05/14 20:38:20 [error] 5349#0:* 828 open()“/example/path/htdocs/administrator.php”failed(2:No such file or directory),client:123.123.123.123 ,server:example.server.com,请求:“GET administrator.php HTTP / 1.1”,主机:“example.server.com” 我可以得到一些帮助制定修正正则expression式string来捕捉这些types的错误? 我想重申,我不主持任何PHP或ASP文件,所以我不太在意这里可能的误报风险。