On Thu, 24 May 2018 16:47:46 +0200 Thuban <thu...@yeuxdelibad.net> wrote:
> Hello, > I need to redirect some URLS with httpd. As example : > > /test/?d=2018/05/02/13/14/50-some-title > > Must be redirected to /2018/05/02/some-title > > My problem is that "?" is never matched. > > Here is the pattern I use : > > location match > "^/test/%?d=(%d%d%d%d/%d%d/%d%d)/%d%d/%d%d/%d%d%-(%g+)$" { block > return 301 "/%1/$2" } > > > Any advice? > After many tests, it seems that the only problem is the "?" > > thanks. > The portion of the URL from the "?" on is the "query string" -- I wonder if that isn't broken off before the pattern matching occurs and simply passed on verbatim to the new location In PHP you could accomplish a quick and easy redirection by creating a file /var/www/htdocs/test/index.php something like this: ===%<----- <?php if(array_key_exists('d', $_GET)) { header('Location: /' . urlencode($_GET['d'])); } else {/* ... */} ===%<----- I believe that the variable $_GET['d'] has already been parsed from the query string and urldecoded. Otherwise, I am looking more into relayd(8) to accomplish redirections and other header manipulation.