By aicbal
I had once moved my blogger site to wordpress. Till then I had to use the following in .htaccess file.
RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/([^/]+).html$ http://mywpsite.com/$3
Now, after moving my site to Nginx, I could not find a way to implement the above rule so that my old permalinks are maintained in new environment also.
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!
The solution above worked partially.
Example:-
http://mywpsite.com/2011/08/one-of-my-post-link.html -> http://mywpsite.com/one-of-my-post-link/ (Success) http://www.mywpsite.com/2011/08/one-of-my-post-link.html -> http://www.anotherdomain.com/2011/08/one-of-my-post-link.html (failure)
You can use nginx’s rewrite directive to implement that:
rewrite ^/([0-9]{4})/([0-9]{2})/([^/]+).html$ http://mywpsite.com/$3 permanent;
I added the code inside the server block but getting error.
nginx -t
nginx: [emerg] directive “rewrite” is not terminated by “;” in /etc/nginx/sites-enabled/wordpress:67
Although, the semi-colon is placed in the code above.
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.