Comment on 301 Redirect Htaccess by SEO Dave.

301 Redirects and www/non-www Canonical ProblemsHmm, after rereading what I suggested the .htaccess option isn’t suitable for all directories like /wp-content/plugins/ it would 301 redirect everything under the folder to home rather than just stop users seeing the contents!

I’ve deleted that part of my earlier comment and pasted below with a better modification to explain what it actually does.

How to 301 redirect an entire directory to home.

You have two directories you no longer use and want to 301 redirect everything that used to be in them to home, this could be thousands of images or webpages.

/wp-content/hidden/
and
/oldstuff/

Add this to your root .htaccess file

Note if “RewriteEngine On” is already within the file it’s not needed again.

RewriteEngine On
RewriteRule ^wp-content/hidden/(.*)$ https://stallion-theme.co.uk/ [R=301,L]
RewriteRule ^oldstuff/(.*)$ https://stallion-theme.co.uk/ [R=301,L]

This would 301 redirect everything under the folders “/wp-content/hidden/” and “/oldstuff/” to my home page.

This can be useful where you’ve deleted hundreds of tags, tags are rubbish SEO wise and should be avoided, if you deleted all your sites tags you could build a set of 301 redirects to conserve the link benefit.

You’ve delete all tags and want them all 301 redirecting:

RewriteEngine On
RewriteRule ^tag/(.*)$ https://stallion-theme.co.uk/ [R=301,L]

You’ve deleted some tags called tag 1, tag 2 and tag 3, but kept tag 5 and tag 5

RewriteEngine On
RewriteRule ^tag/tag-1/(.*)$ https://stallion-theme.co.uk/ [R=301,L]
RewriteRule ^tag/tag-2/(.*)$ https://stallion-theme.co.uk/ [R=301,L]
RewriteRule ^tag/tag-3/(.*)$ https://stallion-theme.co.uk/ [R=301,L]

Tag 1 to 3 will 301, the rest won’t be.

Best to try to find a page that’s similar to redirect to rather than just back to home

RewriteEngine On
RewriteRule ^tag/tag-1/(.*)$ https://stallion-theme.co.uk/ [R=301,L]
RewriteRule ^tag/tag-2/(.*)$ https://stallion-theme.co.uk/post-about-tag-2/ [R=301,L]
RewriteRule ^tag/tag-3/(.*)$ https://stallion-theme.co.uk/responsive/category-3/ [R=301,L]

Above I don’t have a relevant page to tag-1 so 301 to home, but do to tag-2 have a post about tag 2 and have a category similar to tag 3.

I have sites with dozens of 301 redirect rule sets like these.

David