Welcome to WebmasterWorld Guest from 35.171.183.163

Forum Moderators: Ocean10000 & phranque

Message Too Old, No Replies

301 Redirect on folder and contents

     
12:34 pm on Dec 13, 2013 (gmt 0)

Junior Member

10+ Year Member Top Contributors Of The Month

joined:July 4, 2007
posts: 193
votes: 0


I have a Wordpress site where I need to change the url of the category from:

example.com/oldcategory/ to example.com/newcategory/ and therefore also redirect any pages contained to the new folder structure i.e.

example.com/oldcategory/post to example.com/newcategory/post

I need to do this without ruining the SEO on the site. Is this correct…

RedirectMatch 301 oldcategory(.*) newnewcategory/$1

Thanks in advance for any help.
1:17 pm on Dec 13, 2013 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:11715
votes: 211


if you have WordPress, then you are using a mod_rewrite directive for the internal rewrite to the wordpress php script.
RedirectMatch is a mod_alias directive.
these don't mix well in the same server configuration.

http://httpd.apache.org/docs/current/rewrite/avoid.html [httpd.apache.org]:
The use of RewriteRule to perform this task may be appropriate if there are other RewriteRule directives in the same scope. This is because, when there are Redirect(Match) and RewriteRule directives in the same scope, the RewriteRule directives will run first, regardless of the order of appearance in the configuration file.
1:45 pm on Dec 13, 2013 (gmt 0)

Junior Member

10+ Year Member Top Contributors Of The Month

joined:July 4, 2007
posts: 193
votes: 0


Thanks for this. Any ideas on how best to approach this as I don't fancy going through the tens of posts I have in each category and doing individual 301 redirects.
6:11 pm on Dec 13, 2013 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15704
votes: 811


You don't need to redirect each one separately. The pattern will include some part that's always the same-- your "oldcategory" in the first example-- and then some optional extra stuff-- the (.*) in your example.

mod_rewrite uses slightly different syntax from mod_alias. But if you know how to do RedirectMatch, which uses Regular Expressions, you are already halfway there. More than halfway.

It gets trickier if only some parts of "oldcategory" are to be redirected. Is that the problem here? If so, you'll need one or more RewriteCond lines. mod_alias doesn't have these.
6:51 pm on Dec 13, 2013 (gmt 0)

Junior Member

10+ Year Member Top Contributors Of The Month

joined:July 4, 2007
posts: 193
votes: 0


Thanks for this. Found a great plugin called "Simple 301 Redirects"