When asking regex questions, always add the tag for the specific programming language or tool (e.g., Perl, Python, or Java; vi, emacs, or ɢɴᴜ grep; etc.) you are using.

learn more… | top users | synonyms

3
votes
3answers
1k views

Nagios not accepting regex in command

I have this command defined: define command{ command_name check_http_sane command_line $USER1$/check_http -H $HOSTNAME$ -r "HTTP/1.1 (200|301|302|303|304|307|401|418|426)" } When I run it manually ...
0
votes
1answer
256 views

puppet master --compile logs errors to stdout

I see a bug about this that was accepted and then closed a year ago: http://projects.puppetlabs.com/issues/3670 but I'm using puppet 2.7.14 and am getting the same issue. I'm trying to use "puppet ...
1
vote
1answer
494 views

How can I rewrite following url link in nginx?

How can I rewrite following link in nginx? http://www.example.com/filename/key.value/bar.foo to http://www.example.com/filename.php?key=value&bar=foo Notice .php also, please!
2
votes
1answer
98 views

Memory usage REGEX

Could you help me to modify the following one-liner to get more precise memory usage - right now it's just an integer I would like to include first value after coma. free -m | awk '/Mem:/ {tot = $2;} ...
0
votes
1answer
183 views

How to match a string in URI with regular expression?

In my Apache config httpd.conf, I wish to setup a rule like below SetEnvIfNoCase %{QUERY_STRING} ^.*(getBook+)$ no-gzip dont-vary I am hoping to do no-gzip when my URL looks like ...
0
votes
1answer
554 views

How can I store {REQU­EST­_URI} in a variable, manipulate it and then use it in a RewriteCond or RewriteRule

How can I store {REQU­EST­_URI} in a variable, manipulate it and then use it in a RewriteCond or RewriteRule? Basically, here is what I am looking to do. 1.) Get the {REQU­EST­_URI} and change ...
2
votes
1answer
299 views

Sed multi-line replace over escaped strings

I'm attempting to convert a mysqldump output file to PostgreSQL compatible SQL. The issue is in dealing with escaped string values. I need to go from: VALUES('blah blah blah','second string \'with ...
1
vote
2answers
1k views

NGINX Reverse Proxy : proxy_cache inside if block - Possible?

I think starting with a small snippet would be wisest: location ^~ /test/ { proxy_pass http://frontend; proxy_http_version 1.1; ...
1
vote
3answers
223 views

Apache mod_rewrite, multiple variables

I'm struggling a bit with mod_rewrite and replacing multiple variables with regexes. I'm trying to rewrite the following: www.mysite.com/avatars/funny/1 into: ...
5
votes
1answer
399 views

nging pcre_compile error when using quantifiers

I'm having an issue with aliasing. I want to append up to the first 4 digits of the file as part of the directory. (like '../123456.jpg'=>'../123/123456.jpg' and '../12.png'=>'../12/12.png') Here is ...
0
votes
0answers
106 views

RewriteMap and RewriteRule troubleshooting on Apache2

First off, I'm trying to get the following rule working: RewriteMap legacyredirect txt:/var/www/path/to/legacyredirect.txt RewriteRule ...
1
vote
0answers
333 views

Apache LocationMatch does not work for group

I would like to configure Apache to proxy mldonkey running at localhost. Initially I have used the following configuration (in server config): <IfModule mod_proxy.c> <LocationMatch ...
2
votes
1answer
2k views

How do I format this regex so it will work in fail2ban?

I've just installed fail2ban on my CentOS server in response to an SSH brute force attempt. The default regular expressions in fail2ban's sshd.conf file do not match any entries in audit.log, which ...
0
votes
1answer
473 views

Lighttpd $HTTP[“host”] regex matching

I've set up my config like this: $HTTP["host"] =~ "(^|\.)domain1\.com$" { fastcgi.server = ( "/domain1.py" => (( "socket" => "/tmp/fastcgi.socket", "bin-path" => ...
2
votes
2answers
188 views

Regular Expression for “AND”?

Let's say I gave you the following text: allow_httpd_anon_write --> off allow_httpd_mod_auth_ntlm_winbind --> off allow_httpd_mod_auth_pam --> off allow_httpd_sys_script_anon_write --> ...
4
votes
4answers
2k views

nginx rewrite base url

I would like the root url http://www.example.com to redirect to http://www.example.com/something/else This is because some weird WP plugin always sets a cookie on the base url, which doesn't let ...
1
vote
0answers
158 views

Nginx equivalent to lighttpd “evhost.path-pattern”

I'm setting up a new server for my personal stuff. On the old box I've used lighttpd for almost two years now. I've read a bit about it and most people tend to switch to nginx since it's development ...
2
votes
1answer
292 views

Regular expression not working on Powershell

Background: I need to match a multiline pattern(?) in a C# source file. The regular expression will be manipulate by Powershell. I have tested and it works on RegexBuddy (with the Dot Matches ...
4
votes
1answer
709 views

Ack search for literal strings [closed]

I am sick of having to escape things when I want to search for part of an html tag. How can I ack search for exactly what I type without having to escape stuff? e.g. ack-grep 'console.log(foo' I ...
2
votes
1answer
131 views

Recursively search and replace the contents of multiple file types

I have thousands of web files(*.php, *.htm, *.html, etc) that contain an absolute path(http://site.com/sites/etc). I need to scan a directory and all subdirectories for the various file types and ...
1
vote
1answer
233 views

RewriteRule mp3 to php

I want to rewrite all .mp3 files to a php file. And I dont want to pass on the path so http://localhost/somepath/feb.mp3 http://localhost/feb.mp3 shouldn't do any difference. I came up with: ...
1
vote
1answer
173 views

How to redirect all subdomains do one domain in Apache config file without specifying domain name?

I want to make general rule for all my domains, so I don't have to specify each of them individually. I have these two lines in my Apache config file: RewriteCond %{HTTP_HOST} ^domain\.com ...
0
votes
0answers
297 views

How can i test for an environment variable in a RewriteCond

Is there a way to put an environment variable in the condPattern part of a RewriteCond? Here is what i tried: RewriteCond %{REQUEST_URI} /%{ENV:ALIAS}/(js|css|img).* RewriteRule (.*) - [L,NS] But ...
3
votes
1answer
2k views

Fail2Ban SASL Filter Misses Failed Logins

I am using fail2ban on my mail server. I discovered this morning that there were some 5000 failed login attempts (in the course of 1 hour) via SMTP that didn't get picked up by my sasl filter. Here ...
0
votes
2answers
321 views

How do I delete a matching line, the lines above and those below in the section?

In nagios config define service{ use generic-service host_name xxx.xxx.com service_description xxx Status check_command ...
3
votes
3answers
4k views

nginx rewrite append a parameter at the end of an url

I need to configure my reverse proxy so that the following parameter will be added at the end of the url: &locale=de-de This almost works: rewrite ^(.*)$ $1&locale=de-de break; However, the ...
0
votes
1answer
200 views

Mod_rewrite excluding files/directories but including .php files

The traditional mod_rewrite for routing is as follows: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php [L] ...
0
votes
2answers
603 views

fail2ban regex to catch dovecot log entry?

Am trying to write a fail2ban regex that catches anyone who tries the user-id "administrador". For example, this log entry: Jan 2 09:55:01 mail2 dovecot: pop3-login: Disconnected: ...
2
votes
2answers
63 views

Get Apache2.2 to hide Microsoft documents that are being edited?

I have a htdocs directory where I am serving a few Microsoft Word documents. When someone is editing a document, the name of the document changes to look like something like this: ...
0
votes
2answers
3k views

How can I count instances of a regex match in a log file using PowerShell?

I have a very large log file in which I need to count the occurrences of all the variations of a particular string; that is: There are a large number of file IDs that appear in the format AA000####. ...
1
vote
2answers
138 views

weird apache rewrite regex

I'm in the process of migrating a setup from apache to nginx. In this process I've come across this rewrite rule in an .htaccess file: RewriteRule ^/?(?:(?!one|two|three|four).?)+/?$ ...
0
votes
1answer
193 views

.htaccess ModRewrite when moving web root content into subdirectories?

I'm cleaning up and rearranging the files on my server (basic shared hosting situation) and am digging into .htaccess to do so. I'm moving the content I had in my web root into the subdirectory of ...
1
vote
1answer
449 views

RewriteRule: cannot compile regular expression. Version support?

I'm running an Ubuntu 10.04 LTS, Apache version 2.2.14. On httpd.conf I've a rewrite rule that look like this: RewriteRule (*UTF8)^/users/([^/])([^/]+)/(.*)$ /users/$1/$2/$1$2/$3 [L] The idea ...
2
votes
3answers
219 views

How do I find this string?

I'm trying to match these file names with the find command: 4702011-10-21CR719557-R85262-ALPHA.jar 4702011-10-21CR719557-R85262-BETA.jar I'm reasonable familiar with Java-Perl regex syntax. ...
3
votes
2answers
2k views

How can I route some emails to a script in Postfix?

How do I route all emails directed to user-*@example.com (i.e. user-1234@example.com) to a pipe command in Postfix? The idea is to create craigslist-style anonymization by assigning dynamic email ...
2
votes
2answers
706 views

Debugging nginx URL rewrite: How do I figure out where the problem is?

I have a specific URL pattern on a site which needs to be redirected to the HTTPS version. This is a Django site; Nginx checks each URL in memcached, and if it doesn't find a cached version it proxies ...
2
votes
2answers
751 views

fail2ban regex that uses less CPU?

Using fail2ban, I want to ban these spammers who are sending to a spamtrap address: Oct 27 09:04:22 si68 postfix/smtpd[3240]: NOQUEUE: reject: RCPT from unknown[117.197.114.222]: 550 5.7.1 ...
0
votes
2answers
333 views

Nginx: wild card dns redirect URL to subdomain

I'm trying to redirect the following URL Http://example.com/category/something To redirect to Http://something.example.com/category/something Where "something" could be anything. I've already ...
1
vote
2answers
4k views

How to exclude files from TAR archive using regular expressions?

I have a simple question, yet I can't find or solve the answer. I want to make a tar archive, but I want to exclude some files from it using regular expression. Example of the file to exclude is ...
1
vote
2answers
985 views

Postfix virtual domains: how to accept all subdomains except for two?

Assuming my Postfix server serves the domain example.com, I want it to accept mail for all the subdomains of example.com except for mail.example.com and in.example.com. At first I've tried using a ...
3
votes
2answers
513 views

egrep matching group not printing?

I'm trying to create a bash script that will grep lines from a file using egrep. I've created the regex that should group the information I want, the issue is trying to get the output. I've been ...
2
votes
1answer
620 views

Weird 404 issue with nginx 's.png'

This URL is invalid: http://mysite.co.uk/assets/images/whymysite/viewoptions.png However, if I replace the 's' at the end before .png, with ANY other standard character (that I've tried so far, it ...
2
votes
2answers
2k views

Regex negative look-ahead is not working for mod_rewrite between different Apache versions

I have a mod_rewrite line that works under Apache 2.2, but not under Apache 1.3: RewriteRule ^(?!index.php)(?!skin/)(?!js/)(.+) /index.php?file=$1 [NC,L] If I lose the ...
0
votes
1answer
144 views

Apache redirect to another domain all URLs, except for ones starting with substring

Can anyone help me achieve a redirect in Apache from http://subdomain.example.com/ to http://example.com/ for all URLs, EXCEPT the ones starting with "files/"? Thank you
4
votes
3answers
4k views

Regex for sed to grab multiple lines or a better way?

I'm creating a script that connects to a server and dumps the output to a tempfile. I want to use sed in the script to grab specific information from the temp file. The output would always have the 80 ...
0
votes
1answer
335 views

Multiple protected locations with Nginx

I am trying to secure couple of locations using the basic HTTP authentication that comes with Nginx, but for some reason it won't work. I have: website.com/admin (This is accesible by user ADMIN) ...
0
votes
1answer
685 views

(Apache) RedirectMatch regex to match all directories except those in my list

I need to 301 redirect all requests coming in for requests to http://server.com to be redirected to http://newserver.com unless the request is for an arbitrary list of directories we are maintaining ...
2
votes
2answers
728 views

nginx 0.7.65 rewrite not working for double slashes?

Using Nginx 0.7.65, I spent a few hours trying to get what seemed to be a simple nginx rewrite to work. But the two forward slashes don't seem to work properly: Url Before: ...
5
votes
2answers
2k views

rsync: How to exclude Dotfiles only in topmost directory?

When performing backups under Bash with rsync, I'm trying to exclude all dotfiles and hidden directories in the top directory, but not those in otherwise targeted directories. For example: /copyme.c ...
2
votes
1answer
538 views

Why does my SetEnvIfNoCase directive does not match requested URI?

I'm attempting to set up Apache such that various error pages display with headers/footers appropriate to the context of the error. If the user was requesting a corporate page, I want to show the ...