0

I need 301 redirection rule for migrating old CMS to WordPress.

On old CMS I have URL structure like this:

I wish is to move my site to WordPress and to have all old (or most) URLs with 301 redirect to new pages.

Category url on old CMS:

www.my-site-name.com/category-name-some-category-suffix/

www.my-site-name.com/category-name-some-category-suffix/page/2/

www.my-site-name.com/category-name-some-category-suffix/subcategory-name-some-category-suffix/

www.my-site-name.com/category-name-some-category-suffix/subcategory-name-some-category-suffix/page/2/

Post urls on old CMS.

www.my-site-name.com/category-name-some-category-suffix/subcategory-name-some-category-suffix/some-post-name.jpg.html

and one add-on page for every post like:

www.my-site-name.com/full-size/category-name-some-category-suffix/subcategory-name-some-category-suffix/some-post-name.jpg-some-words-here.html


Category url on WordPress:

I have for example "category_url" as category base, also I wish to remove "-some-category-suffix" from category, and subcategory (if any).

For category URLs to:

add "category_url/" after domain name

remove "-some-category-suffix" from category, and any subcategories

to redirect to URL like this:

www.my-site-name.com/category_url/category-name/

www.my-site-name.com/category_url/category-name/page/2/


Post urls on WordPress.

My permalink structure is "category-url/%category%/%postname%.html". Please note difference between category base "category_url" and post base "category-url".

For post page to:

remove "-some-category-suffix" from category, and any subcategories

rename ".jpg.html" to ".html"

to redirect to URL like this:

www.my-site-name.com/category-url/category-name/subcategory-name/some-post-name.html


For post add-on page to:

remove "-some-category-suffix" from category, and any subcategories

rename "full-size" to "category-url"

rename ".jpg-" to ".html-?"

remove ending ".html" (after "-some-words-here")

to redirect to URL like this:

www.my-site-name.com/category-url/category-name/subcategory-name/some-post-name.html-?some-words-here


Summary.

Category from:

www.my-site-name.com/category-name-some-category-suffix/

to:

www.my-site-name.com/category_url/category-name/

Post from:

www.my-site-name.com/category-name-some-category-suffix/subcategory-name-some-category-suffix/some-post-name.jpg.html

to:

www.my-site-name.com/category-url/category-name/subcategory-name/some-post-name.html

Post add-on page from:

www.my-site-name.com/full-size/category-name-some-category-suffix/subcategory-name-some-category-suffix/some-post-name.jpg-some-words-here.html

to:

www.my-site-name.com/category-url/category-name/subcategory-name/some-post-name.html-?some-words-here

Any help would be great, if rewrite rules are not possible for all URL types than please for some of them.


I tried this:

#For post page URLs
RewriteRule ^(.*)-some-category-suffix(.*).jpg.html(.*)$ /category-url/$1$2.html$3 [L,R=301]

#For post add-on page URLs
RewriteRule ^full-size/(.*)-some-category-suffix(.*).jpg-(.*).html(.*)$ category-url/$1$2.html-?$3$4 [L,R=301]

#Category URLs
RewriteRule ^(.*)-some-category-suffix(.*)$ /category_url/$1$2 [L,R=301]

It works, if there is just one category level, it removes just last "-some-category-suffix".

Output examples

For post pages

www.my-site-name.com/category-url/category-name-some-category-suffix/subcategory-name/some-post-name.html

or for post add on page

www.my-site-name.com/category-url/category-name-some-category-suffix/subcategory-name/some-post-name.html-?some-words-here

or for category

www.my-site-name.com/category_url/category-name-some-category-suffix/subcategory-name/

I need little tweak of it to remove all instance of "-some-category-suffix" if more than one in URL.

If you can fix that and make other rules that would be nice.

Any advice, help?

  • 1
    What have you already tried in for rewrite rules in .htaccess? WPSE is not a "give me the codes site." Have you searched for an answer? wordpress.stackexchange.com/search Tell us what you found and why it didn’t meet your needs. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and above all, it helps you get a more specific and relevant answer. – markratledge Feb 8 '14 at 14:46
  • ** RewriteRule ^full-size/(.*)-some-category-suffix(.*).jpg-(.*).html(.*)$ category-url/$1$2.html-?$3$4 [L,R=301] ** It works, if there is just one category level, it removes just last "-some-category-suffix". www.my-site-name.com/category-url/category-name-some-category-suffix/subcategory-name/some-post-name.html-?some-words-here I need little tweak of it to ** remove all instance of "-some-category-suffix" ** if more than one in URL. If you can fix thiat and make other rules that would be nice. – Advanced SEO Feb 8 '14 at 15:12
  • I updated my rewrite roles, but still I need little help. – Advanced SEO Feb 10 '14 at 14:29
0

I made modification of rules, now it is working fine.

#For post page URLs
RewriteRule ^(.*)-some-category-suffix(.*)-some-category-suffix(.*).jpg.html(.*)$ /category-url/$1$2$3.html [L,R=301]

#For post add-on page URLs
RewriteRule ^(.*)full-size/(.*)-some-category-suffix(.*)-some-category-suffix(.*).jpg-(.*)(.*).html$ /category-url/$1$2$3$4.html?-$5$6 [L,R=301]

#Category URLs
RewriteRule ^(.*)-some-category-suffix(.*)-some-category-suffix(.*)$ /category_url/$1$2$3 [L,R=301]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.