Welcome! Log In Create A New Profile

Advanced

Re: How to do substitions (like perl s/// operator) in rewrites?

Maxim Dounin
January 10, 2010 09:32AM
Hello!

On Sun, Jan 10, 2010 at 09:08:48AM -0500, bartschipper wrote:

> I recently migrated a web site from Apache to Nginx (and from CMS-system x to CMS system y)
> Almost all of the rewrites are OK in the new CMS, except for one older class of article URLs:
> http://example.com/News/Articlepage-News/This-is-the-best-News-EVER.htm (example)
>
> The direct mapping for these literal urls to the new urls is lost.
> I do however have a file (200k+ entries) that maps the titles to article-id's like so:
>
> # old-class-urls.txt: (first two commented lines are not actually in the file)
> # all lowercase title without spaces and hyphens article-id
> thisisthebestnewsever 123456;
> ...

[...]

> map $uri $old-class-url {
> include /etc/nginx/rewrites/old-class-urls.txt;
> }
> ...
> server {
> ...
> location ~* ^/News/Articlepage-News/.*htm {
> rewrite ^/News/Articlepage-News/(.*)htm $1 ;
> ###
> ### change $uri to lowercase and remove the hyphens...
> ### I am looking for something equivalent like in perl:
> ### s/-//g;
> ### s/.*/\L{$1}/;

There is no easy way to do this without perl as of now. With
embedded perl it's trivial though.

Maxim Dounin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

How to do substitions (like perl s/// operator) in rewrites?

bartschipper January 10, 2010 09:08AM

Re: How to do substitions (like perl s/// operator) in rewrites?

Maxim Dounin January 10, 2010 09:32AM

Re: How to do substitions (like perl s/// operator) in rewrites?

dobe January 10, 2010 12:09PM

Re: How to do substitions (like perl s/// operator) in rewrites?

bartschipper January 11, 2010 03:28AM

Re: How to do substitions (like perl s/// operator) in rewrites?

bartschipper January 11, 2010 04:18PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 176
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready