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)

2
votes
1answer
1k 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: ...
2
votes
1answer
401 views

Regexp in HAProxy's reqrep for asset management

I'm hosting assets on S3 with this kind of URL: http://cdn.site.com/image.jpg In my application I automatically serve versioned URL to force browser to download new files after the deployment: ...
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 ...
2
votes
1answer
170 views

Logcheck: wildcards which include non-latin characters

On my mail server, I have a custom logcheck rule as follows, which is intended to filter messages from deliver: ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ deliver\.*\): msgid=.*: saved mail to.*$ ...
1
vote
1answer
111 views

Show real server name in nginx logs and params passed to fastcgi?

I have configured my nginx vhosts with a regex in server_name. nginx shows the raw regex in logs and in params passed to php-fpm (I know there's $_SERVER['HTTP_HOST'] with a real value, that's not an ...
1
vote
1answer
137 views

fail2ban jail not working properly

I'm trying to block non-available script requests to nginx with fail2ban. # Noscript filter /etc/fail2ban/filter.d/nginx-noscript.conf: # # Block IPs trying to execute scripts such as .php, .pl, ...
1
vote
1answer
79 views

Problematic Mail Sieve rules

I need top classify my incomming emails using this three rules: if the email was send to any @somedomain.tld, then copy that email to "somedomain_tld" if the email was send to any other @*.tld , ...
1
vote
1answer
548 views

Question Mark ? Regex exchange transport rule

I'm trying to use the following Regex in exchange 2010 transport rules. Edit: Apologies - I wasn't very clear. I'm trying to match the question mark. I have escaped the question mark but still tells ...
1
vote
1answer
207 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 ...
1
vote
1answer
527 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 ...
1
vote
1answer
198 views

htaccess for wildcard subdomains

How to translate the example URL to the needed one? From http://test.at.domain.com To http://domain.com/at/index.php?at=test I have: RewriteEngine on RewriteCond %{HTTP_HOST} ...
1
vote
1answer
373 views

Moving mod_rewrite rules in .htaccess to httpd.conf

I've got a massive set of URL rewriting rules that I am trying to: optimize transition to use within httpd.conf But I'm facing problems in getting the final product to work. Note: There are ...
0
votes
1answer
27 views

sudo : wildcard in user/group name

I try to find a solution about a sudo problem. I need to push different sudoers files on different servers, depending on the users present on the servers. But I would like to know if I can avoid that ...
0
votes
1answer
46 views

Apache 2.4 AliasMatch NotWorking

I used to Alias have as below for /CollabPortal14300 which was working fine Alias /CollabPortal14300 D:/Dev/Projects/CollabPortal/CollabPortal/target/CollabPortal/ Alias ...
0
votes
1answer
44 views

How to update multiple registry key values using regex?

I am looking for a way to use regex in reg add command in order to update multiple registry key values. Is there any way to do this? reg add "HKEY_USERS\.DEFAULTS\Control Panel\Desktop" /v ...
0
votes
1answer
19 views

Varnish 3 ignore the req.backend directive

Varnish3 is ignoring the req.backend directive. As explained on the documentation (here), I've set two backends, and the regex for redirecting the request to the correct one. By the way, seems liks ...
0
votes
1answer
64 views

Puppet: Nagios with regex node names

I am configuring a puppet master and want to rely heavily on hiera. Many of my systems will be almost identical due to being scalable. I have therefore created node manifests which use regex rather ...
0
votes
1answer
96 views

lighttpd Regex for automatic forwarding of subdomains

I have been looking round and I have not found a good way to automatically set the document root for domains automatically. For example: In the DNS, *.mydomain.com points to mydomain.com And in the ...
0
votes
1answer
449 views

Change default document root for all subdomains in directadmin

is there any way to set document root for all subdomains to a different path like: (www/path/subdomains) using regexps or something else? something like this? |*if SUB="*"| ...
0
votes
1answer
55 views

nginx rewrite and Drupal

My web root is in /staging/ and I'm currently using this rewrite line: location / { # This is cool because no php is touched for static content try_files $uri @rewrite; } ...
0
votes
1answer
148 views

Nginx Config File Regex Issue

I am trying to convert the following rewrite rule into a 'try_files': location ~* \.(css|js) { if (!-f $request_filename) { rewrite ^/wp-content/w3tc/min/(.+\.(css|js))$ ...
0
votes
1answer
126 views

Samba share content filtered based on regex rules

I would like to create a Samba share that filters the contents of a directory based on a series of regular expression matches against file names. For example, I would like the share to allow access to ...
0
votes
1answer
228 views

Regex matching specific details if first match exists, multiline

I'm struggling to get the correct regex to match specifically 'Contact' and 'User-Agent' only if the 'Contact' address matches 10.0.x.x in ~70GB of SIP messages. The SIP message will always contain a ...
0
votes
1answer
342 views

Matching req.http.Host in Varnish via Regex vs Standard Operators

I am able to do either of the following: Host match using standard operators: if (req.http.Host == "domain1.com" || req.http.Host == "domain2.com") { ... } Host match via regex: if (req.http.Host ...
0
votes
1answer
671 views

Nginx alias and regex

i'll need a bit of help for alias on folder with nginx I have my folder www/ with the container of my site example.com and a lot of folder like client0, client1, client2... I should NOT modify ...
0
votes
1answer
216 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
396 views

Modify swatch conf files to match multiple lines below a match

We use swatch for reading PHP logs and email them to us. Currently it emails one single line of the error, but fails to match the next few lines of stack trace. For example: for log file like this: ...
2
votes
0answers
38 views

List subfolders somewhere in the path with rsync

I'm developing a program, that will recursively "walk" through Linux repositories, look for PXE-related files and create gPXE configs. I met across a problem with the structure of Ubuntu catalogs on ...
1
vote
0answers
34 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; ...
1
vote
0answers
22 views

Apache2 mod_rewrite, handling the optional “/” at the end of a URL

I am attempting to host a single custom page to set as my homepage on my server. The real path to the page is example.com/start.html. However, I do not want this ugly URL in my homepage so I am ...
1
vote
0answers
23 views

SED returning error 2 when launched by Wpkg

Case I am deploying a software product using Wpkg over Windows workstations. I need to disable product's faulty automatic update and the best solution in this case is to modify one configuration file ...
1
vote
0answers
135 views

varnish - multiple catch-all domain names

In order to avoid setting up one backed per subdomain, I am specifying a catch-all regex string per domain name, as follows: backend domain1 { .host = "10.10.10.5"; .port = "80"; } ...
1
vote
0answers
44 views

Unable to match expression inside If directive no matter what

I have been trying for the past 3 hours trying to match an if statement to define a variable within httpd.conf with no success: <If "%{HTTP_HOST} =~ /[a-z]+/i"> Define test_value "A" ...
1
vote
0answers
163 views

Exchange 2013 Mail flow rule using RegEx

We're trying to implement a rule on certain mailboxes that it shouldn't accept an email without a subject. I found documentation from Microsoft on exchange 2010 to Configure a Transport Rule for ...
1
vote
0answers
52 views

How to convert RewriteCond rules so they work in Lighttpd?

How can I convert this Apache rewrite rules so they work on Lighttpd? This is in fact a .htaccess file, and I need to put those in a lighttpd.conf file. Options +FollowSymLinks RewriteEngine on ...
1
vote
0answers
101 views

Nginx - Adding a trailing slash to urls on HTTPS

I am using the below regex to add a trailing slash to any url that doesn't have a railing slash or ends ends with .. rewrite ^([^.]*[^/])$ $1/ permanent; This works fine for http, but when I use ...
1
vote
0answers
91 views

PHP UTF-8 bondary regex does not work

I have a CentOS 6 with newest updates running a LAMP stack. A user is complaining that his code does not work and he is trying to use preg_match with unicode characters. This is the code not ...
1
vote
0answers
483 views

Squid Random Shared ip proxy

Running Squid with a acl random ip setup, Have 745 ip's in the pool and we are about 10 users that use it with tools that are running multiple threads, Check rankings on Google etc Issue: We did ...
1
vote
0answers
408 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 ...
0
votes
0answers
32 views

Finding and renaming directories by regex in linux

I'm trying to match (and later rename) directory names like: A0000 (SOME-NAME) A0001 (SOME-OTHER-NAME) A0001 (ANOTHER-NAME) I'm testing to see if I match any using the find command but doesn't seem ...
0
votes
0answers
8 views

Fail2ban apache-myadmin regex

I've got a jail set up with the following regex, which I took from a standard filter file: apache-myadmin.conf failregex = ^[[]client <HOST>[]] File does not exist: *myadmin* *\s*$ ...
0
votes
0answers
24 views

Writing a fail2ban multiline regex

I've got some troublesome hosts trying it on with an SSH server I run, and I'm trying to ban them using fail2ban. Problem is, I haven't done much work with regexes, and even less with Python regexes. ...
0
votes
0answers
41 views

Regex validation : simple hotlink prevention while allowing search engines (and their localized versions)

I made and tested a simple hotlink prevention .htaccess and wanted to validate it here before putting it in production. <IfModule mod_setenvif.c> SetEnvIf Referer mysite\.com|localhost ...
0
votes
0answers
38 views

php-fpm: Maintain php_mod logging format

I recently switched all my lab servers from apache pre_fork/mod_php to apache worker/fcgi/php-fpm, and after getting everything set-up correctly, I noticed one last issue; php-fpm is adding it's own ...
0
votes
0answers
7 views

mod_rewrite: Use Substitution from Previous Condition

I'm trying to do a basic language redirect based on a cookie. To do that and prevent a loop, I need to check that the user isn't already on the correct URL, so I wrote this rule: RewriteCond ...
0
votes
0answers
96 views

Graylog2 date extractor from tab-delimited file

I have a tab-delimited logs with such messages: 2014-06-01 00:00:56 192.168.1.1 968 http://yandex.ru I can extract date and time with regexp (\d{4}-\d{2}-\d{2}\s*\d{2}:\d{2}:\d{2}) but when I ...
0
votes
0answers
65 views

Issue with a NGINX Location regex

I'm just dealing with a location issue today, I have a customer domain with the following format: subdomain.domain.tld and urls as: subdomain.domain.tld/servicename I'm trying to forward this ...
0
votes
0answers
50 views

Negative match for IP based RegEx

I am looking for negative matching for the below IP based regular expression: True-Client-Ip: ...
0
votes
0answers
67 views

htaccess Rewrite leading zero in url causing trouble

I have a database with a string column made up of four unique digits attached to each record. I know this isn't the best way to do this but I'm kind of stuck with it. I'm trying to rewrite urls from ...
0
votes
0answers
187 views

Multi-line regex replacement in apache

I need to do multi-line replacement in apache2, an mod-substitute only does single line matching AFAIK. I need to be able to do something like this: replace <script> foo = x; bar = y; alert(x ...