I used to own a WP blog integrated into my shopping cart but had since abandoned it. It has 3 WP categories (new-arrival, news, promotion)
nginx log still show crawlers trying to crawl my blog links: e.g.
/public_html/new-arrival/
/public_html/new-arrival/launch-72/
/public_html/news/
/public_html/promotion/25-percent-off/
I want to redirect matching (new-arrival | news | promotion) directories to my home page => https://www.example.com
location / {
rewrite ^/(new-arrival|news|promotion|feed)/(.*) https://www.example.com/$1 permanent;
...
...
}
[results] IE https://www.example.com/promotion/ => This page can’t be displayed IE https://www.example.com/promotion => my custom 404 page FF/Chrome https://www.example.com/promotion/ => my custom 404 page
What should be the correct set of 301 redirects?
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!
I’d try something along these lines:
location ~ /(new-arrival|news|promotion|feed)/(.*) {
return 301 https://www.example.com;
}
Adding $1 to the end of your your rewrite (https://www.example.com/$1) will pass on the full path in your rewrite which you don’t want if you just want to send the user to your homepage. Also you generally want to prefer using return rather than rewrites.
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.