Questions tagged [regular-expressions]

107 questions
0
votes
1 answer

NGiNX and MediaWiki rewrite regular expression

I am having some problems with regular-expression with rewrite in NGiNX. Here is my config: location /wiki/ { rewrite ^/([^?]*)/([^?]*)(?:\?(.*))? /$1/index.php?title=$2&$3 last; } Here is the URL of the main page:…
jnbdz
  • 897
  • 5
  • 22
  • 43
0
votes
2 answers

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 ((?.+)\.)?(?.+)\.(?.*); This will create a 3…
redn0x
  • 1
  • 3
0
votes
1 answer

Regular expression to match non-www and non-specified host (nginx)

server { listen 80; server_name ~(?!^www\.)(?!thehost.org); return 301 $scheme://www.$host$request_uri; } I'd like for the server_name to match otherhost.org and differenthost.org, and then return a 301 to…
Devin
  • 101
  • 1
0
votes
1 answer

JunOS Regular Expressions for AS Path

I want to write a regex in Juniper MX960 router for BGP including 3 AS paths with first element is constant, second and third are wildcard. I found that we can put as numbers manually like this: "9121+ (one|two|three|...) (one|two|three|...)". This…
h0m3r
  • 25
  • 10
0
votes
3 answers

How to clear contents of all the files using find command

Is there an easy step to clear contents of all ".log" file using find command. Currently i am using "echo -n > filename.log" i have tried echo -n > /var/application-logs/*.log but it is not working.. is there a better way to clear contents of…
hariharan
  • 3
  • 1
  • 3
0
votes
1 answer

apache virtualhost: Auto subdomain with exception

I've been searching for a way to automatically redirect domains to a specific folder, and fond a good answer here on serverfault: Apache2 VirtualHost auto subdomain. (The accepted answer) So far everything works good, however now I need to add an…
0
votes
1 answer

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: .. Line1: PHP Fatal error: something bad happened…
Stewie
  • 537
  • 2
  • 7
  • 17
0
votes
2 answers

Use regular expression in definition of virtualhost

I have to define about 100 subdomain virtualhost entries in server config file . I want to know if there is any way to do it with regular expression to increase codes in apache config file?
0
votes
3 answers

grep out unique senders from a huge list of emails

I just found a huge list of emails under my user account in Centos /home/user/mail/new I opened some of them and noticed they were sent from a particular cron job. From address is root@hostname.com. I need to find out if all these emails were sent…
gAMBOOKa
  • 979
  • 6
  • 18
  • 33
0
votes
1 answer

Help with regexp in tag of .htaccess

For poorly configured Apache servers you can have to do something like this to deny access to the .htaccess file: order allow,deny deny from all I would like to deny access to all system files (.* - any file that it's…
Activist
  • 13
  • 1
  • 3
0
votes
1 answer

Can I have IIS rewrite rules write to a file?

Extendng on my question at Is it possible to write a regular expression that catches a match that others have missed in IIS? I would like to know if I can have the rewrite rules write to a file. For example if the file test.aspx is not found and…
PeanutsMonkey
  • 1,832
  • 8
  • 26
  • 27
0
votes
2 answers

Is it possible to write a regular expression that catches a match that others have missed in IIS?

I have written a list of regular expressions that currently redirect unused pages to the appropriately used pages e.g. if someone were to request abc.aspx it redirects them to home.aspx in IIS however seeing that I cannot account for all pages is…
PeanutsMonkey
  • 1,832
  • 8
  • 26
  • 27
0
votes
1 answer

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 "\u002fmeis2\u002f[X] I'm not sure how the Regex works in…
SeanKilleen
  • 1,073
  • 8
  • 25
  • 38
0
votes
1 answer

How to redirect web request to some page with NOT condition in Apache

I want to redirect all requests for NOT(main.php) to handelrequest.php?page=[page] So it must be something like: RewriteRule !(main.php) handlerequest.php?page=$1 or RedirectMatch !(main.php) handlerequest.php?page=$1 but it seems, that those…
Rodnower
  • 179
  • 3
  • 12
0
votes
1 answer

Apache mod_rewrite reg expression

I have to manage a huge web site which has coded with absolute paths like: link to another page in the site. Now, as I previously said, the web site has many pages and I'm not paid for…
IssamTP
  • 175
  • 3
  • 12