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 (1)

-1
votes
0answers
19 views

Multiple regex statements to match

How can I manage email headers to reject all emails from specific email domain with specific filetypes? For example. If @gmail.com and filetype is .exe then reject. if /name=.*.exe/ if ...
2
votes
6answers
8k views

Renaming files in linux with a regex

I had a group of files that I'd like to consistently rename, the files are named things like "System-Log-01-01-2009-NODATA.txt" "Something-Log-01-01-2009-NODATA.txt" And I wanted them as lowercase, ...
0
votes
2answers
3k views

Zabbix 2.0: Regular Expression to extract value from a String for a trigger?

I am using Zabbix 2.0.4 to monitor several Java applications. Most values are exported via JMX. One of those exported attributes is a string that is constructed like this: ...
0
votes
0answers
9 views

Remove .php extension only in certain directory - web.config

I'm having trouble making the pattern for matching the urls in a certain directory. I want to redirect users from mysite.com/posts/some-post.php to mysite.com/posts/some-post meaning that I want to ...
0
votes
1answer
15 views

puppet node name with regex

I am running puppet 3.7.3 on a windows 8.1 client and it is pulling in my default node definition. I am trying to create a more generalized definition by using regex on a group of nodes. Our naming ...
2
votes
1answer
1k views

nginx regex characters that require quoting?

So I was configuring nginx today and I hit a weird problem. I was trying to match a location like this: location ~ ^/([0-9]+)/(.*) { # do proxy redirects } ...for URLs like ...
0
votes
0answers
13 views

Nginx return status code from regex grouping

How can I have nginx return a status code from a regular express match? location ~* "^/([\d]{3})" { return $1; } Returns an error 'invalid return code "$1"' I'm trying to setup a test ...
3
votes
3answers
7k views

Using sed to remove both an opening and closing square bracket around a string

I'm running this command in a bash shell on Ubuntu 12.04.1 LTS. I'm attempting to remove both the [ and ] characters in one fell swoop, i.e. without having to pipe to sed a second time. I know square ...
0
votes
0answers
15 views

Removing query strings for a certain location

I am using nginx, and I want to remove query strings on a request in such a way that: With this code, it's not happening. I get a 404 on /store/name. /store/name?page=1 becomes /store/name location ...
-1
votes
0answers
23 views

Nginx and Regex: Can it do what I want?

Consider the following request string: http://<website>/<LotsOfOtherInformation>;SetCamera:Camera5-SetText:TextField1:$sometextinput$-SetText:TextField2:$somedifferenttextinput$ There's ...
1
vote
1answer
35 views

NGINX: Rewrite numeric URL segment with prefix

I'm aiming to have some old URLs work with the new CMS we're migrating to, but it can't support purely numerical URL slugs for some reason, so the new system has them as "/calendar/event/old-42" ...
1
vote
2answers
4k views

How do I match a wildcard host in ACL lists in HAproxy?

I have the following lines in my haproxy.conf: acl valid_domains hdr(Host) -i mysite.com images.mysite.com docs.mysite.com admin.mysite.com redirect location http://mysite.com/invalid_domain if ...
1
vote
1answer
29 views

Determine if an e-mail contains a certain number of a specific character

I am hoping to write a SpamAssassin rule that will match if an e-mail contains over n of a specific character in the body of the message. Not necessarily continuous. So for example, if there were ...
1
vote
1answer
41 views

Command substitution into bash script $1 value

I have this simple script which changes permissions on my apache2 websites /var/www/html# cat permissions_setup.sh chown -R root $1 chgrp -R www-data $1 chmod -R 750 $1 chmod g+s $1 I have two .sh ...
2
votes
1answer
2k views

nginx return 301 / redirect

among all 'redirect in nginx' questions I couldnt find how to redirect (using return 301 and beteer no ifs) using regexps. I have a link to my website and I'd like to remove parameter a the end: ...
0
votes
3answers
300 views

Nginx add trailing slash without rewrite

I am trying to create redirect to add trailing slash, location / { if($request_uri ~ ^([^.]*[^/])$){ return 301 https://$host$request_uri/; } } I have no idea how to do ...
0
votes
0answers
17 views

How to pass parameter when using apache mod headers SetEnvIf

I'm new to apache proxy regex - mod_headers and would like to know the following I'm trying to Set and Environmental if the value field of a Request header 'Referer' matches like this: SetEnvIf ...
0
votes
2answers
66 views

NGINX Proxy_Pass remove url substring

I have one NGINX acting as reverse proxy. I need to remove a substring string_1 from the URL, the rest of the URL is variable. Example: Origin: http://host:port/string_1/string_X/command?xxxxx ...
0
votes
1answer
9 views

Failure htaccess regax

I'm trying to get all request to the server to go to the index.php file with the request information. Also, I want to prevent accessing the index.php file directly. The second part works fine but I ...
0
votes
2answers
341 views

nginx dynamic servername with regular expression doesn't work for co.uk

I'm trying to setup a nginx server which dynamically loads content from a folder for a domain. To do this I'm using regular expressions in the server name like so: server_name ...
2
votes
1answer
19 views

Apache2 LocationMatch allow an index for login but nothing else?

I want to allow /myapp and /myapp/ but disallow everything else. How do I configure this? I tried this: <LocationMatch "^/myapp/.+$"> LDAP here </LocationMatch> Which I would assume ...
0
votes
0answers
23 views

nginx rewrite url issue

Current rewrite URL : rewrite ^/link/(.*)/(.*)/(.*)/$ /link.php?one=$1&two=$2&three=$3 last; What I need is solution so three link samples work: 1) /link/one/ 2) /link/one/two/ 3) ...
0
votes
1answer
73 views

Nginx rewrite, removing image dimensions from filename

For instance, if a request is made to an image like so... /static/images/00f37ac6291bb6e8_150.jpeg But the 150px thumbnail version hasn't been generated yet and returns a 404, I would like to have ...
3
votes
3answers
3k views

Nginx location regex doesn't work with proxy pass

I'm trying to get these 2 location directives working in Nginx but I'm getting some errors back when booting Nginx. location ~ ^/smx/(test|production) { proxy_pass ...
0
votes
2answers
37 views

exim: redirect all but a number of local parts

On my server, I implement redirects using this router virtual_aliases: driver = redirect allow_defer allow_fail data = ${lookup{$local_part@$domain}wildlsearch*@{/etc/vhosts/forwards}} ...
0
votes
0answers
9 views

Apache rewrite to tidy up image urls [duplicate]

I am using the htaccess file that ships with the skeleton application for Zend Framework 2. Here it is: Options -Indexes RewriteEngine On # The following rule tells Apache that if the requested ...
3
votes
1answer
632 views

nginx error log Grok pattern

I am having trouble getting the following nginx error log message to parse in the grok debugger. I have a feeling there is a stupid trick that I should use but can't figure out what it may be. ...
0
votes
1answer
116 views

Modify fail2ban failregex to match failed public key authentications via ssh

fail2ban doesn't recognize failed public key ssh logins and I assume that this can be solved by modifying the failregex of /etc/fail2ban/filter.d/sshd.config to match the following line: <date> ...
-1
votes
7answers
3k views

Is it possible to have regular-expression CNAME record in DNS?

Is it possible to do something like this? Or any equivalent? in a DNS server. ([0-9]{2})\.example\.com\. IN CNAME www$1.example.net.
0
votes
2answers
2k views

apache - query string rewrite rule appends condition to URL

In trying to rewrite site-search.html?searchword=search%20term as advanced-search#q=search%20term I always end up with advanced-search#q=%3Fsearchword%3search%20term The %3Fsearchword%3 ...
2
votes
1answer
55 views

htaccess regex not processing URLs properly

I'm trying to redirect (or 'rewrite') over 3000 urls for a site where we updated the SEF of most of the content pages to remove an ID number that was not needed/desired. This should be a simple ...
0
votes
1answer
120 views

nginx config - replace/rewrite all dead links on a page. Add prefix to the uri

I want to inject "project name" to every link on a web page. Example: link and site http://localhost/osqa/ is working, but when I'm on the osqa page, all links are directing to localhost directly ...
0
votes
2answers
74 views

nginx: regex not matching URI

i have this URI /orls/myservice/f?p=4550 and the following location location ~ "^/(.+)/myservice/f?p=(.+)$" { ..... } nginx is returning a 404 not found. the problem might come from the ? so i ...
0
votes
1answer
149 views

nginx - regex captures for multiple locations

Creating regex captures for multiple locations. Tree structure: /home/user/webapps/ ├── index.html <= content: root. ├── osqa │ ├── index.html <= content: osqa test A. │ ...
1
vote
1answer
370 views

Regex for multiple sshd Received disconnect from … [preauth]

What fail2ban regex would catch logs like these? Apr 9 08:48:28 server sshd[1856]: Received disconnect from 43.255.190.117: 11: [preauth] Apr 9 09:06:05 server sshd[1936]: Received disconnect ...
0
votes
1answer
51 views

Nginx: location regex not working

i'm getting trouble with my regex don't know what is wrong with it. it's returning a URi with orls/f instead of orls/f?p=4550. When i pass https://secure.toto02.com/orls/myservice/f?p=4550 my conf ...
2
votes
3answers
128 views

Regex Replace Append Filename

How can I append characters to a files name in linux, using a regex? I've seen these two posts http://stackoverflow.com/questions/6985873/change-names-of-multiple-files-linux How to rename multiple ...
0
votes
3answers
73 views

Is there an option in Apache to check PHP files for malicious code before parsing them?

Basically, I would like Apache to check PHP files for certain patterns before parsing them. If these PHP files match the patterns, I would like to send something else in replacement back to the user. ...
0
votes
1answer
280 views

why Apache's setEnvIf doesn't set correct header and how to debug it

I have the following in my .htaccess file: <IfModule mod_headers.c> SetEnvIf Origin "http(s)?:\/\/(www\.)?(inreado\.local|testenv\.inreado\.com|inreado\.com)$" AccessControlAllowOrigin=$0$1 ...
1
vote
1answer
113 views

nginx regex location not matching

I have the below location below, which is among a larger conf file. As reference, this works: location = /scripts/news/admin/index.js { alias /my/file/path/news/scripts/admin/index.js; } ...
1
vote
0answers
30 views

rsyslog regex global modifier

Many regex systems have the ability to set a global modifier to allow for multiple matches. Here's how it works in Javascript and Perl. /g Python is a little different Python doesn’t have a ...
0
votes
0answers
77 views

systemd logcheck rule not working

given is this logcheck rule: ^\w{3} [ :[:digit:]]{11} [._[:alnum:]-]+ systemd-logind\[[[:digit:]]+\]: New session [[:digit:]]+ of user [^[:space:]]+\.$ and this log entry: Mar 19 09:16:09 horst ...
2
votes
1answer
2k views

SetEnvIf regex for setting Content-Disposition HTTP header

I am attempting to use the IHS 7.0/apache 2.2 SetEnvIf directive to set the filename of a downloaded file based on a url parameter. I think I am pretty close, however if there is a space (encoded or ...
0
votes
1answer
69 views

nginx location regex /yyyy/mm/dd/

I'm trying to pass requests from address example.com/donor/2014/12/07/Name on the other server. URIs are like /donor/2014/12/07/Mike and I need to convert them to a query type of: ...
1
vote
1answer
138 views

postfix header_checks - regex spanning multiple lines

I would like to create a spam filter that spans multiple lines in headers. This is my /etc/postfix/header_checks file: /^From:.*name[0-9]+@.+[\r\n]+To:.*name@domain\.com/ REJECT It's a valid ...
0
votes
1answer
149 views

Nginx - redirecting non-www to www, but not subdomains

I have many domains linked to the same php directory, and I need all of them to redirect from non-www,non-https to www,https. # Add www, if missing server { server_name ...
1
vote
1answer
163 views

Block attachment files without extensions in Postfix via mime_header_checks?

We know how to reject executables and other potentially dangerous file extensions via mime_header_checks directive: mime_header_checks = regexp:/etc/postfix/mime_header_checks (main.cf) ...
2
votes
0answers
328 views

nginx subdirectory to subdomain icingaweb2

I currently have icinga2 set up with the new icingaweb2 ui. it defaults to the subfolder /icingaweb as follows: location ~ ^/icingaweb/index\.php(.*)$ { # fastcgi_pass 127.0.0.1:9000; ...
2
votes
2answers
676 views

Sieve: filter subject with regex, file into mailbox named match

I am trying to filter mails by subject with a regular expression. The subjects I want to match are read like [git-foo] some more text where foo is the string I want to check for. I end up with the ...
0
votes
1answer
72 views

Proxy action for user-agent blocking with regular expressions not blocking

I have a server behind a Watchguard XTM firewall and want to block incoming RESTClients who has certain user-agents in their request headers. I have implemented several rules to do this: List image ...