Welcome! Log In Create A New Profile

Advanced

Re: Comprehensive Rewrite Rules / Regular Expressions Guide?

April 01, 2009 06:28AM
On Wed, Apr 01, 2009 at 12:27:49PM +0200, J?r?me Loyet wrote:

> 2009/4/1 Ole Rehmsen <lists@ruby-forum.com>:
> > Hey everyone,
> >
> > I want to modify some rewrites I currently have in my nginx.conf, but I
> > could not find proper documentation of the available operators and
> > language constructs to do so. Googling I found tons of people trying to
> > convert rewrite rules from apache to nginx, but since I have never used
> > apache, this is not very helpful to me. Is there some document
> > explaining all supported operators for the regular expressions?
> >
> > For example, I have something like $host ~* "www" in my config, and from
> > the context I can guess that ~* seems to check whether the left hand
> > side contains the right hand side. But I did not find a proper
> > specification in any regular expressions guides.
>
> I think this should make the trick:
>
> if ($host !~* "^www.exemple.de") {
> rewrite ^(.*)$ http://www.exemple.de$1 permanent;
> }

No.

server {
server_name www.example.de;
...
}

server {
server_name _; # any names

rewrite ^ http://www.example.de$request_uri? permanent;
}

> >
> > My current problem at the moment is that I want to say something like
> > "if the domain used is not already www.example.de, than change it that
> > way". I want that all example.com, example.org... are rewritten to read
> > www.example.de. So I need to know wether there is a possibility to
> > negate a condition, or something like "unless" or so. However, this is
> > only one problem I have right now, I would very much like to understand
> > the bigger picture and all the options I have in rewritting stuff. Is
> > there a document listing those options?
>
> http://wiki.nginx.org/NginxHttpRewriteModule
> and
> http://wiki.nginx.org/NginxHttpCoreModule#Variables

--
Igor Sysoev
http://sysoev.ru/en/
Subject Author Posted

Comprehensive Rewrite Rules / Regular Expressions Guide?

Ole Rehmsen April 01, 2009 06:04AM

Re: Comprehensive Rewrite Rules / Regular Expressions Guide?

Jérôme Loyet April 01, 2009 06:27AM

Re: Comprehensive Rewrite Rules / Regular Expressions Guide?

Igor Sysoev April 01, 2009 06:28AM

Re: Comprehensive Rewrite Rules / Regular Expressions Guide?

Ole Rehmsen April 01, 2009 06:56AM

Re: Comprehensive Rewrite Rules / Regular Expressions Guide?

mike April 01, 2009 06:50AM

Re: Comprehensive Rewrite Rules / Regular Expressions Guide?

Igor Sysoev April 01, 2009 07:32AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 55
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready