WordPress.org

Ready to get started?Download WordPress

Forums

Redirect all posts to new domain (but not JPG files) (4 posts)

  1. bayridgeodyssey
    Member
    Posted 2 years ago #

    I have moved all content from an old domain to a new one, and I'd like the old site to redirect to the new.

    I already have a root-to-root redirect set up using this code in the theme's index.php file:

    '<?php
    header( 'Location: http://www.bayridgeodyssey.com/', true, 301);
    ?>'

    I'd like to redirect all of the posts to their corresponding post on the new site, i.e.:

    http://www.bksouthie.com/2010/10/memories-of-borough-park/
    ...to...
    http://www.bayridgeodyssey.com/2010/10/memories-of-borough-park/

    http://www.bksouthie.com/2012/01/seen-on-third-avenue-lowens/
    ...to...
    http://www.bayridgeodyssey.com/2012/01/seen-on-third-avenue-lowens/

    I would assume that there is some similar code I can add to single.php, but I don't know.

    There are about 550 posts - I'd like to avoid doing something manual that lists each one, but it is possible.

    Also, I want to make sure references to files (like JPG or PNG images) do not get redirected (I didn't transfer any of the old pictures).

    Any ideas?

  2. dean_l
    Member
    Posted 2 years ago #

    hi bayridgeodyssey

    below articles may help you
    http://yoast.com/change-wordpress-permalink-structure/

    there is a nice tool or at least it can give you a start.
    cheers

  3. thecodeisclear
    Member
    Posted 2 years ago #

    @dean_l. Thanks for the link. I am thinking of making the permalink change (as suggested by Yoast)

  4. luckdragon
    Member
    Posted 2 years ago #

    why not just do a .htaccess redirect on the server?

    like:

    RewriteCond %{REQUEST_URI} !\.(gif¦jpe?g¦png)$
    RewriteRule (.*) http://www.whatever.com/ [L,QSA]

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags