Say you have a URL www.answers.mydomain.com/category/hello_world-123.html but you want to rewrite the path part as /category/hello-world
How would you go about that with an nginx rewrite? Basically how can I format the $1 variable?
server{
listen 80;
server_name ~^(?<subdomain>.+)\.bg\.com$
root /home/dan/Projects/rewrite-example;
set $PREFERRED_DOMAIN $scheme://www.bg.com;
if ($subdomain ~* answers) {
rewrite ^(.*)$ $PREFERRED_DOMAIN/questions$1 permanent;
}
}