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
786 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 ...
4
votes
3answers
5k 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
163 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
6k 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 ...
6
votes
2answers
3k 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
601 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 ...
0
votes
2answers
550 views

How to use RegEx for mod_security

I have a directory/site set-up like this on my Apache/2.2.19 (Win32) Server using mod_security + core ruleset/2.2.1 /website1/login.php /website2/login.php /website3/login.php /websiteN/login.php ...
1
vote
3answers
4k views

apache locationmatch negative regex

I'm trying to expose a location through Apache. Normally, I have this block in my vhost that says <Location /> AuthType Basic AuthUserFile /web/.htpasswd AuthName "Test Site" ...
0
votes
2answers
130 views

grep pattern matching for case insensitivity

I wanted to write a grep function to show me all listening ports on my host. I know how to do it by using the -i function in grep : netstat -a |egrep -i 'listen' But now I wanted to write it in ...
1
vote
2answers
160 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
2answers
524 views

need to redirect to static url based off of string patter match in uri

I have siteminder protecting an Oracle ADF java faces app. It appears I am going to have to intercept an http reqeust for the logout link delivered by Oracle in order to kill the siteminder session. ...
0
votes
2answers
109 views

Optimal mod_rewrite regex. Does the way the matching patterns are arranged inside the regex matter?

I have the following: RewriteRule ([a-zA-Z0-9]{5})?/load_page/([0-9]+) Which arrangement would be optimal for the regex: RewriteRule ^/([a-zA-Z0-9]{5})?/load_page/([0-9]+) OR RewriteRule ...
0
votes
1answer
848 views

Is it possible to match more than one regular expression with a single <ProxyMatch> rule?

I have a production, testing, and development server for a site that I maintain. All three servers are running Apache 2.2.16 on Debian 6 GNU/Linux. I have set up a new version of our company site on ...
1
vote
3answers
638 views

How to use Apache Piped Logs to regex replace out unwanted data in logs in real time?

I have https_acces_log log files being generated by Apache that a certain web app is logging unwanted data into the file. I can't stop the app from logging the data, so I'd like to write a ...
0
votes
1answer
51 views

Help with simple mod_rewrite needed

My site uses mod_rewrite for most URL's within the site. eg. domain.com/contact.htm domain.com/product/details.htm I've had domain.com/contact.htm working for a long time and is quite simple, but ...
0
votes
1answer
681 views

How to match this URL with PERL REGEX in SQUID?

I am trying to match this URL but Its not working not matching at all ... ...
2
votes
2answers
787 views

nginx rewrite config

I'm pretty new to nginx and am trying to setup some pretty simple rewrite rules, but they don't seem to be working. Just for your info, this server { .. } has its server_name domain.com *.domain.com. ...
2
votes
2answers
681 views

apache question mark RewriteRule question

So i am trying to redirect from index.php?action=search&query=search text goes here to search?query=search text goes here i tried this so far but with no luck RewriteRule ^search/? ...
0
votes
1answer
355 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
838 views

HAProxy reqirep setting results in 504 Gateway Timeout

I am trying to rewrite a single path via HAProxy. Without the rule in place, a 404 is returned for the directory page (from an IIS node). Once I add the rule, the page returns a 504 Gateway Timeout ...
1
vote
2answers
1k views

Simple URI redirection / alias in Nginx

Please, how can I make this simple operation in Nginx: I wish that every requests for uris like: http://example.com/adm or: http://example.com/adm Goes to the wordpress login page: ...
1
vote
1answer
202 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} ...
4
votes
4answers
6k views

Copy multiple folders to a single destination with robocopy

I'm looking for a solution to use robocopy to copy several folders from a directory onto a distant network share. I want to choose several folders out of a directory that contains hundreds of folders ...
1
vote
2answers
1k views

Watchguard Firewall WebBlocker Regular Expression for Multiple Domains?

I'm pretty sure this is really a regex question, so you can skip to REGEX QUESTION if you want to skip the background. Our primary firewall is a Watchguard X750e running Fireware XTM v11.2. We're ...
1
vote
1answer
356 views

What regular expression can I use to identify invalid file requests in nginx logs?

I need help configuring a regular expression for fail2ban. I use my web server primarily for simple podcast file hosting but I see a lot of invalid requests for php, asp, and pl files in the logs. ...
0
votes
1answer
370 views

Pop-before-smtp $pat regex for Dovecot in iRedmail

I've installed pop-before-smtp in my mail server(iredmail). I need help to configure the $pat to read the pattern of my Dovecot file. Dovecote log file is like this: 2011-05-14 14:01:21 pop3-login: ...
2
votes
1answer
176 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.*$ ...
2
votes
2answers
3k views

nginx location regex matches directory range

I am trying to set up nginx and I don't get the point how to do the following setup: I have an URL http://somehost.com/foo/bar/123/xxx_xxx that needs to be passed to different backends depending on a ...
4
votes
2answers
257 views

Why does a $1 backreference work in a rewrite with no subgroups?

Someone I'm working with committed a RewriteRule such as the following to SVN: RewriteRule ^admin/ebay.*$ /yii.php/$1 [L] I warned him that it may not work because there is no subgroup in the match ...
2
votes
2answers
331 views

URL rewrite on custom Wordpress site

I've been tasked with modifying an existing Wordpress site with URL rewriting. Problem is I've never done this before. I know these rules should go in a .htaccess file in root with something like this ...
0
votes
5answers
164 views

Sed regexp /d deleting whole file

Given a typical known_hosts file: [123.45.67.89]:22 ssh-rsa bbuivvhbkbjdnflksndkfnksnfk... [98.76.54.32]:14444 ssh-rsa hohdibsodbfoasbfbsabdfbsd... [77.34.122.33]:32209 ssh-rsa ...
1
vote
2answers
111 views

ignore lines grep

I have a very annoying message being output from a process I'm running. I'd rather not remove the line, but simply remove it with grep The messages to ignore all contain the word "requests". I could ...
2
votes
2answers
792 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 ...
1
vote
1answer
303 views

Basic Apache Log Regex

I'm struggling to match Fail2Ban's failregex on Apache logs using only the HTTP return codes. The log format I'm using is below and in that example it's the field showing "200". As long as the other ...
2
votes
2answers
718 views

Rsync and wildcards

I am trying to back up both the "Last Session" and "Current Session" files for Google Chrome in one command, but using a wildcard doesn't seem to work. I am trying with the following command rsync ...
2
votes
2answers
858 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: ...
0
votes
1answer
371 views

Move all images in folder to subfolder, and update all references to those images to their new location?

I have a folder which contains a ~50 text files (PHP) and hundreds of images. I would like to move all the images to a subfolder, and update the PHP files so any reference to those images point to the ...
1
vote
2answers
2k views

RegEx Match URL Pattern

I'm trying to come up with a regex pattern that will match any domains in this format: example.com but not this: subdomain.example.com Currently it needs to only cover the main TLDs (com, net, ...
0
votes
1answer
702 views

Apache mod_proxy_html Substitute: how to re-use part of regex match? (regex variables?)

Have a unique URL-rewriting situation in Apache. I need to be able to take a URL that starts with "\u002f[X]" or '\u002f[X]" Where X is the rest of some URL, and substitute the text ...
1
vote
2answers
294 views

Why do two patterns (/.*) and (.*) match different strings?

Shouldn't the two patterns (/.*) and (.*) match the same string? My real question is actually: where did the "abc" go? Something funky seems to be happening inside the mod_rewrite engine... Given ...
0
votes
1answer
530 views

What is this mod_security rule trying to prevent?

Today my IP was blocked by my server. I was told it was because of a mod_security rule that got triggered. I'm told that the regex that got triggered was ^((?:(?:POS|GE)T|OPTIONS|HEAD)) I don't ...
0
votes
1answer
749 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 ...
1
vote
1answer
429 views

Need help on awk/sed/ perl pattern with regex / grep

Sample file output from grep file1:my $dbh = DBI->connect("dbi:mysql:$database_name", $DB_USER, $DB_PASSWD) file2:($dbc,$rc) = mysql_connect($mysql_host,$mysql_user,$mysql_password); The awk ...
1
vote
1answer
533 views

ForceType/SetHandler code - why does this work?

I tried this code, although it works for some reason, aren't there mistakes in it? I'm not sure what the best way to correct this is, but here it is... <Files .+*^$[]()> ForceType ...
1
vote
1answer
385 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
466 views

(\d+) and ([0-9]+) htaccess rewrite not working on new server, works fine on old server

RewriteRule ^mp3/(\d+)/(.*)/$ download.php?id=$1 [L,NC] is the specific rewrite rule I am trying to get working....it was working fine on my old server but now I am on a server with Apache 1.3.4.1 ...
1
vote
2answers
285 views

mod_rewrite rule

I need a mod_rewrite rule that sends all requests to index.php unless the request is for anything in the /media/ folder. I have a similar rule for lighttpd but I don't know enough about ...
1
vote
3answers
482 views

Request exceeded the limit of 10

My logs are FULL of [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' ...
2
votes
2answers
125 views

Make shortened and long urls play together on the same domain (RewriteRule)

Long story short, I want to have both example.com/aJ5 and example.com/any-other-url working together. I'm using apache and not very good at writing regex. I have already a global RewriteRule which ...
1
vote
1answer
148 views

Unrestricted access to a single file + FastCGI with basic_auth for whole domain in nginx

What's the easiest way to restrict access to all files except one, where whole domain is served via FastCGI? The problem occurring when below conf is used, is that I cannot access /dir (I'm asked for ...