Redirect old urls to archive page - wordpress

I need to 301 redirect some old urls to the category archive page.
Here's an example of the old url structure that need to be redirected:
domain.com/vetrina/name-post-1
domain.com/vetrina/name-post-2
domain.com/vetrina/name-post-3
etc.
Since those pages don't exist anymore I simply need to redirect them to the archive page of the category:
domain.com/category/vetrina
What is the correct way to do that in the .htaccess file?
Thank you :)

You can use RedirectMatch directive
RedirectMatch 301 ^/vetrina/.+$ http://example.com/category/vetrina

Related

Setup 301 redirect for .html pages Wordpress

Hi I have migrated my store from Magento to Wordpress, I want to set up 301 redirects for the product pages they were /product.html but now are just /product I used the following code in the .htaccess file, which works but it makes the homepage break, how can I alter this code to make the homepage still work?
redirectMatch 301 ^(.*).html$ $1
You can ignore the index page:
redirectMatch 301 ^(?!/index\.html$)(.*)\.html$ $1

Wordpress 301 Redirect

I have got one Wordpress blog site and I use permalink as:
%category%/%postname%.html
I want a change as:
%postname%.html
And now old urls (https://www.example.com/category/post-name.html) 301 redirect to (https://www.example.com/post-name.html).
How can I redirect with use .htaccess file?
Just go to wp-admin, then /settings, then /permalinks and select "Post name". More info on that here: https://codex.wordpress.org/Using_Permalinks
For 301 redirects you can write your own to your htaccess file but this is probably not as easy as using a plugin like Simple 301 Redirects.

301 Redirect htaccess Change URL Structure

I'd like to redirect all pages from a Wordpress multi-site installation to another Wordpress installation - e.g. website.com/blog/blog/page to website.com/our-blog/page
Using redirect 301 / http://www.website.com/our-blog/ doesn't work because the visitors are redirected to website.com/our-blog/blog/blog/page. Does anyone know how to remove the /blog/blog?
Thank you!
You can use RedirectMatch:
RedirectMatch 301 ^/blog/blog/(.+)$ http://www.website.com/our-blog/$1

redirect only home page to a separate page wordpress multisite

In my WordPress multisite, I need need my subsite home page to redirect to a different page. Like site.com/subsite or site.com/subsite/ should redirect to site.com/subsite/home/ .
Redirect 301 can do this but, it will also redirect site.com/subsite/search?q=param1 to site.com/subsite/home/search?q=param1 . But it should not.
wp_redirect will do same.
Thanks
You want to use RedirectMatch instead:
RedirectMatch 301 ^/subsite/?$ /subsite/home/

301 redirect help - .htm removed and few urls changed

I'm moving content from an old dreamweaver site to a new wordpress site, all file names are the same, except the new wordpress one's don't have the .htm at the end.
Some category/subcats slugs are changed.
I'm wanting to 301 the domain and all pages to new domain name.
Most urls:
Old content url: http://olddomain.com/reviews/soft/graphics/filename.htm
Where new page will be: http://newdomain.com/reviews/soft/graphics/filename
A few categories/subcats:
Old: http:// olddomain.com/reviews/hard/sound/filename.htm
New: http:// newdomain.com/reviews/hard/sound-review/filename
What would the 301 htaccess file look like?
(note: both old and new urls have the www. in them, the old domain also needs all non-www redirected too)
Appreciate any help
What would the 301 htaccess file look like?
In the htaccess file in your olddomain.com document root:
RedirectMatch 301 ^/([^/]+)/([^/]+)/([^/]+)/(.*)\.htm$ http://newdomain.com/$1/$2/$3/$4

Resources