Rewrite regex with percent signs

redrobes nginx-forum at forum.nginx.org
Sun May 22 11:16:35 UTC 2016


Hello, I am helping an admin sort out some 404 issues by using some rewrite
which have generally been successful. However we have a couple of cases that
are a bit mysterious and hope you can help explain. This is from a vbulletin
forum that used to use the vbseo extension to make the url's prettier but
that extension has been dropped now so posts with those pretty url's don't
point the correct places.

For example, we have a url of the following:
/members/redrobes-albums-2d%20vs%203d%20?-picture12345-mt-pub01.jpg

it needs to go to

/attachment.php?attachmentid=12345

we have:

location /members/ {
rewrite ^/members/.+-albums-.+-picture(\d+)-.*
/attachment.php?attachmentid=$1? redirect;
}

and this particular one is not working. It works with many others where the
original url did not have the %20's in them. So there is something about
those %20's that are causing these to fail.

I can write a perl script and run that url through its regex and it does
change them.

So what does the nginx regex do different from perl regex with regard to %
signs.

Thanks.

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,267039,267039#msg-267039



More information about the nginx mailing list