I've got problem with making rewrite rule in nginx and i need your help. How to make rewrite rule from http://www.example.com/2015/03/link-to-page.html to http://www.example.com/link-to-page/ I've tried this
location / {
rewrite "^/([0-9]{4})/([0-9]{2})/(.*)\.html?$" /$1/ redirect;
}
but it's not working. Thank you
That looks like you are matching the entire url. The "^" at the beginning is the start of the string, not the exclude character.
rewrite "^/\d{4}/\d{2}/(?<domain>.+)$" http://$host/$domain permanent;
The domain variable is regex name. It can be anything.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.