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)

4
votes
1answer
127 views

Apache MatchRedirect exception regex

I want to redirect any URL that is Https and hasn't start with "system_" to the same URL with http. for exapmle for this url : https://exsite.tld/some/thing/that/not/start/with/pattern to : ...
0
votes
1answer
1k views

Nginx location override does not do what I want, opinions welcome

I have a Nginx configuration file that works for everything except one feature. I have installed a Mediawiki, it works pretty well except at showing pictures (loading them works fine). Whereas (sorry ...
1
vote
1answer
1k views

Regular expressions in server_name with Nginx vhost

I have something I'm trying to do with Nginx. Say I have a few users and a subdomain, and each user has a directory at /home/dev/sites/USER_ID. I would like for USER_ID.dev.example.com to point to ...
1
vote
1answer
972 views

rsyslog - template - regex data for insertion into db

I've been googling around the last few days looking for a solid example of how to regex a log entry for desired data, which is then to be inserted into a database, but apparently my google-fu is ...
-2
votes
1answer
32 views

Regex help for .htaccess

I want to exclude access to certain files using .htaccess files but i need help generating the correct regexp. I want to exclude access to these two files: soft1-pp_1.12-123456789010_amd64.deb ...
0
votes
0answers
48 views

mod_rewrite rule should be matching, but isn't [duplicate]

I've only started editing rewrite rules a few days ago, before now I'd copy and paste them for each case. I've written a rule which as far as I can tell*, should be matching but isn't RewriteRule ...
0
votes
1answer
2k views

Extracting matches in NGiNX with regex without if block

With NGiNX I get a string that contains information that I can extract content with regex. But the only way I found that I could do this, is with if block. Is there any another way? The extracted ...
1
vote
1answer
862 views

Nginx - Redirect request by GET parameters pattern

One of my servers was attacked by DDoS a couple of days ago and it lasted for 4 days. Below are the logs snippet of the request: 36.224.180.253 - - [14/May/2013:03:11:46 +0800] "GET ...
1
vote
1answer
61 views

Nginx 404 rewrite issue

I'm trying to grab variables between slashes and pass them to my management script with the following rewrite line in Nginx: rewrite ^/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)$ ...
0
votes
2answers
390 views

How can I replace an apostrophe in a URL using htaccess?

I have a website with a search box on it. The search term is passed to the search page as part of the $_GET (I'm using PHP, but I think that's irrelevant to the problem I'm having), so my final url ...
0
votes
2answers
2k views

nginx simple regex location

I need to set a location param in nginx if the first 5 digits of the url are numbers. site.com/12345/ or site.com/12345 But I can't for the life of me seem to get the correct regular expression. ...
1
vote
1answer
783 views

How to block all incoming proxy visits except from one specific I.P?

I have a page that is prone to attacks, so, in order to reduce the anonymous attacks, I use this code in my .htaccess which I found online : # BLOCK PROXY VISITS <IfModule mod_rewrite.c> ...
3
votes
1answer
637 views

How do I use “catchall” in my postfix alias?

I have this in my main.cnf: alias_maps= regexp:/etc/aliases Inside that file, I have: /^reply*$/: jjj Now, when I send it to reply-124233@mydomain.com, postfix bounces it because Recipient ...
1
vote
2answers
133 views

The meaning of * in Basic regex versus Extended regex

I thought * meant zero or more of the character or class that precedes it in basic or extended regex. Why does echo hello| grep '*llo' fail but echo hello |egrep '*llo' succeed?
0
votes
4answers
276 views

Move files to subdirectories: /img/ab123.jpg --> /img/ab/ab123.jpg

I have a linux webserver with about 25.000 images in one directory. They are all lowercase and in the format two letters, three digits and jpg as the extension. Because that many files in one folder ...
-1
votes
1answer
200 views

Some regex for powershell [closed]

I have below sample file(s). Symmetrix logical device count=13 CLARiiON logical device count=0 Invista logical device count=0 Generic logical device count=0 ...
0
votes
0answers
194 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 ...
0
votes
1answer
60 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
440 views

How to have nginx serve only the home page of site?

I am running a server with nginx on port 80 and Apache on 8080. I want the home page of my site to be served with nginx, and every other request passed through to Apache. I found this great article ...
1
vote
2answers
50 views

Perl regex expression

I have the following string produced by a server log file. I am using Simple Event Correlator (which uses perl regex) to manipulate lines: 18:37:31 643.65.123.123 []sent ...
2
votes
2answers
2k views

Nagios check_http - checking tomcat application status with regex & linespan

I wan't to check with our Nagios if a webapplication is running on Tomca7. I decided to use the check_http plugin with regex. I'm parsing the status-page of tomcat and check if column "Running" is ...
0
votes
1answer
214 views

Debian, Search and replace iframe injection [duplicate]

We're running a Debian server and we have a malware or something doing code injection. I know how to search and replace this string : <iframe src="http://ingvar2000.no-ip.org/jc/rss.php" ...
0
votes
1answer
1k views

nginx httpMapModule regex variables

The HttpMapModule documentation states that: Since 1.0.4, case insensitive regular expressions can be used by prefixing the pattern with ~*. And gives the example: map $uri $myvalue { /aa ...
0
votes
1answer
165 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))$ ...
1
vote
1answer
2k views

pcregrep is not matching regex (multiline?)

I don't understand why is first two is a match/hit, yet third is a miss? -bash-3.2# cat 1361492805.M171838P41834.mx1.alexus.biz\,S\=12921\:2\,Sijm | pcregrep -q '.*languager.*' ; echo $? 0 -bash-3.2# ...
1
vote
0answers
96 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 ...
0
votes
1answer
196 views

.htaccess rewrite: how to remove all directories but the first and second?

I'm trying to get a specific .htaccess rewrite done, but my regex skills are limiting me to do so; example 1: www.domain.com/dir1/dir2/dir3/file.txt should become www.domain.com/dir1/dir2/file.txt ...
0
votes
2answers
226 views

Lighttpd vhost regex

I'm having a problem with my vhosts using regex. When I use the following code, I get a 404 not found: $HTTP["host"] =~ "(^|\.)example\.com$" { ... } However, when I explicitly set it to the ...
1
vote
2answers
142 views

Grabbing the directory path in a message like “You have new mail in /var/spool/mail/root”

So I often get messages such as You have new mail in /var/spool/mail/root and end up typing/copy-pasting out: tail /var/spool/mail/root, which is a bit cumbersome. Is there a simple command that ...
1
vote
1answer
56 views

Mod_Rewrite Rule (or an Alternative) For Reorganizing Directory Structure [closed]

The website I work on had these two pages in the past: http://www.africananimals.com/stripes/zebras and http://www.africananimals.com/news/zebras (These are not actual domain names, just ...
1
vote
1answer
2k views

replacing a line or date in a text file using powershell

I am trying insert today's date on a text file at line 59. How do i do this? Line 59 has like 30 spaces and then reads like this. After the PowerShell script runs it will change the date so it has to ...
0
votes
1answer
156 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
230 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
374 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 ...
1
vote
2answers
575 views

centos - how to find a filename with all the possible extensions?

I need to perform a search for "foo" and return all the filenames/ directories with this name (e.g. foo.php, foo.txt etc ). It should run through the whole filesystem and find even hidden files . ...
0
votes
1answer
86 views

Htaccess regex working strange

I am trying to write .htacess file that would catch urls like: http://www.site.com/pageone.html http://www.site.com/pagetwo.html and redirect them to index.php so it would receive 'pageone' and ...
2
votes
2answers
5k 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 ...
-2
votes
2answers
347 views

NTP server hostname validation regex [closed]

I want make basic syntax validation of NTP server hostnames. (For example, I expect %^$&" is a syntaxticly invalid NTP server hostname.) The reason I want to make this basic validation is because ...
-3
votes
1answer
929 views

Apache FilesMatch directive - “Multiple arguments not (yet) supported”

What the heck... There's only one argument, the regex. Earlier in the file, I denied all. Now I just want to allow access to index.php, as well as images, css, and javascript. <FilesMatch ~ ...
0
votes
1answer
3k views

postfix header_checks using regexp proper setup

I just can't seem to figure out why header_checks are not being evaluated. I'm on Ubuntu 12.04, postfix 2.7, dovecote, spamassasin, clamav, amavis. I add following line to /etc/postfix/main.cf : ...
-1
votes
3answers
69 views

perl remove two slashes regex [closed]

I have file wich has many lines inside All lines that contain file=/aaaaaaa/bbbbbbb/cccccc/dddddd.txt it needs to be stripped to this format file=/dddddd.txt i am executing perl in bash ...
-1
votes
3answers
2k views

Trouble Letting Users Get to Certain Sites through Squid Proxy [closed]

We have Squid running on a RHEL server. We want to block users from getting to Facebook, other than a couple specific sites, like our organization's page. Unfortunately, I can't get those specific ...
0
votes
1answer
222 views

Unexpected varnish behaviour of regsub

According to the varnish documentation, the regsub method should not result in a 301 redirect. Yet that is what seems to be happening in my case (that is, the url actually changes in the browser). ...
-1
votes
3answers
106 views

Rename tons of files

How can I rename all the files with a pattern like this: thumb_f318d8a580ca5717d686a323b6c2ca0d.jpg0000777 thumb_f18d8aup90ca5717d686a323b6c2c5uh.jpg0000777 ...
0
votes
2answers
621 views

Nginx RegEx to match a directory and file

I'm wondering if it's possible to match Wordpress directory and specific file in the same location, so at the moment I've got rule to match only the wp-admin directory: ## Restricted Access ...
0
votes
1answer
57 views

htaccess not properly rewriting urls

This is a bit of a weird one. I'm doing some work on a server, and I need rewrite rules for directories that actually exist (in some cases, they are more than one level deep) At the moment my ...
1
vote
1answer
361 views

htaccess rewrite rules to match dynamic params

My base url looks like this. http://localhost/test/s/beer-drinks And depending on the users input it can be something like this. ...
1
vote
0answers
507 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
1answer
342 views

Mechanism behind user forwarding in ScriptAliasMatch

I am following this tutorial to setup gitolite and at some point the following ScriptAliasMatch is used: ScriptAliasMatch \ "(?x)^/(.*/(HEAD | \ info/refs | \ objects/(info/[^/]+ | \ ...
0
votes
2answers
1k views

How to combine RewriteRule of index.php and queries rewrite and avoid Server Error 404?

Both RewriteRule's works fine, except when used together. 1.Remove all queries except query ?callback=.*: # /api?callback=foo has no rewrite # /whatever?whatever=foo has 301 redirect ...