wordpress 301 redirect old domain to new domain

Discussion in 'WordPress' started by prince@life, Jan 3, 2012.

  1. #1
    I own domain at http://www.mysite.net
    and recently i have purchased http://www.mysite.com

    I am using Wordpress.
    I have transferred all files from old domain to new domain and chaged corresponding posts and pages links in mysql database.

    Now i am facing problem is that...

    when user tries to open link, tag or categories its not opened :(
    in fact, i want to redirect as follow..

    http://www.mysite.net/software-tags must redirect to http://www.mysite.com/software-tags

    http://www.mysite.net/download-categories must redirect to http://www.mysite.com/download-categories

    http://www.mysite.net/first-post must redirect to http://www.mysite.com/first-post


    Anybody have solution ??

    I want to do it thorugh .htaccess .


    See below code that i have tried . but not working well :(
    I have latest version of wordpress that is 3.3

    # BEGIN WordPress

    <IfModule mod_rewrite.c>

    RewriteEngine On

    RewriteBase /

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule . /index.php [L]

    </IfModule>



    # END WordPress

    RewriteEngine On

    RewriteCond %{HTTP_HOST} ^.*mysite\.net$ [NC]
    RewriteRule ^(.*)$ http://mysite.com/$1 [R=301,L]



    PLEASE HELP ME !!
     
    prince@life, Jan 3, 2012 IP
  2. BRWebConsultingLtd

    BRWebConsultingLtd Member

    Messages:
    45
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    28
    #2
    Hey, I had this problem once!

    Try something like this:

    Options +FollowSymlinks
    RewriteEngine on
    rewritecond %{http_host} ^mysite.net [nc]
    rewriterule ^(.*)$ http://www.mysite.com/$1 [r=301,nc]

    Enjoy!
     
    BRWebConsultingLtd, Jan 4, 2012 IP
  3. Yojance

    Yojance Greenhorn

    Messages:
    16
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    13
    #3
    Check your wp-config.php file to make sure you are not defining the site url or home url there.
    Look for something like this:

    define('WP_HOME', 'youroldsite.com');
    define('WP_SITEURL', 'youroldsite.com');
    PHP:
    If you see that, just change it to your new domain or delete it if you have updated the values in your .sql file under the options table.
     
    Yojance, Jan 5, 2012 IP
  4. тнє Sufi

    тнє Sufi Peon

    Messages:
    391
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Here goes the solution:

    Go to root folder of your old domain. Create a .htaccess file (if already exists, just modify it). Put the following code in it.

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L] 
    Code (markup):
    Replace newdomain.com with your new domain. You are set to go :)
     
    тнє Sufi, Jan 9, 2012 IP
  5. тнє Sufi

    тнє Sufi Peon

    Messages:
    391
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Remember, 301 redirection code must be set to old domain root folder, not in the new domain. So remove all redirection code from the new domain .htaccess file.
     
    тнє Sufi, Jan 9, 2012 IP