problem in 301 redirect to new domain

Discussion in 'PHP' started by shailenderkumar, Feb 19, 2013.

  1. #1
    I would like to redirect my old domain to new domain. I'm using WordPress on both domains. But my problem is whenever I try to upload .htaccess file for old domain folder, it instantly get deleted and won't show up in root folder. I'm sure what's causing this issue. Is there any other way to 301 redirect my old domain or how would I make sure that .htaccess file get uploaded in root folder.
     
    shailenderkumar, Feb 19, 2013 IP
  2. innozemec

    innozemec Active Member

    Messages:
    84
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    68
    #2
    there's something on your server deleting the .htaccess.. so just ask your host support about it..

    you can do the 301 redirect by simply creating a blank index.php with the code:


    <?php
     
    header('Location: http://www.mynewdomain.com/');
     
    exit;
     
    ?>
    Code (markup):
     
    innozemec, Feb 19, 2013 IP
  3. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #3
    Your host surely has a file manager of some kind... if you browse through that you will see your .htaccess file, plus you should be able to edit it from there if needed.

    Alternatively, your domain provider should have a system in place where you can redirect domain names, look for Domain Forwarding or wording like that. This method will also eliminate any additional hosting costs, you might be incurring.

    Note! if you use your domain providers system to redirect a domain, its usually automatic but you may need to reset your nameservers to match your domain providers.
     
    Last edited: Feb 20, 2013
    MyVodaFone, Feb 20, 2013 IP
  4. Nedzad Mesic

    Nedzad Mesic Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #4
    You can use the php code:
    <?
    Header( "HTTP/1.1 301 Moved Permanently" );
    Header( "Location: http://www.new-url.com" );
    ?>
     
    Nedzad Mesic, Feb 27, 2013 IP