Hi everyone!
I’m using NGINX with Worpdress on my site and would like to do some 301 redirects.
My site currently has permalinks: http://site.com/2017/10/29/post-example/ and would like to switch to http://site.com/post-example/
But I already have more than 120 articles published and ranked by Google and would not like to lose this ranking.
I would like to know how to redirect these links without having to do one by one.
I did a search and found a website that says that you need to enter the following lines:
location ~ “^/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.)$" { rewrite "^/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.)$” http://site.com/$4 permanent; }
My question is: Is this code correct? Where should I enter these lines? I tried inserting into my nginx.conf file and then tried putting it in .htaccess. But I was not successful, because redirection is not being done after changing the permalinks.
If anyone can help me, I will be very grateful.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
you can use this to redirect all of your old links to new domain’s respective links.
you have to put it inside of your old site’s config file (etc/nginx/sites-available/config-file-name.conf) within server { tag.
location / { rewrite ^(.*)$ http://example2.com/$1 redirect; }
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.