Mobile app version of vmapp.org
Login or Join
Pierce454

: Redirecting single URL with Nginx - not working I have been trying to redirect several single URLs to their new locations using Nginx. The URLs are from Blogger and are in the format: http://domain.com/yyyy/mm/slug.

@Pierce454

Posted in: #Nginx #Redirects #Server

I have been trying to redirect several single URLs to their new locations using Nginx. The URLs are from Blogger and are in the format: domain.com/yyyy/mm/slug.
For example, I have this: example.com/2013/04/chartjs-javascript-library-for-easy.html
I am using this Nginx rewrite to redirect it, but for some reason it doesn't work:

server {
location ~ /([2012-2013]+)/.*/chartjs-javascript-library-for-easy.html {
return 301 $server_name/resource/chart-js; }
}


I place this in /etc/nginx/conf.d/example.conf which is loaded inside /etc/nginx/nginx.conf

Can anybody tell me why it doesn't work? It was working sometime back. Am I messing up my regex?

EDIT:

For some reason, location /test redirects ok, but location /test/html doesn't. Any idea why?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Pierce454

1 Comments

Sorted by latest first Latest Oldest Best

 

@Megan663

Note that [2012-2013] doesn't mean what you think it does :) [] is a character class, not a number class :)

Try location ~ ^/201[23]/.*/chartjs-javascript-library-for-easy.html

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme