WordPress.org

Ready to get started?Download WordPress

Forums

Best Way to Redirect 301 (11 posts)

  1. raadmunir
    Member
    Posted 11 months ago #

    Hi

    Well i am transfering all of my data from old site to new one. including posts. i.e. i want to on site A there was a page called /mypage.html and i want that when user click on this url from search page it will be redirect to new site containing same page. I tried to do a 301 redirect using "

    <?
    Header( "HTTP/1.1 301 Moved Permanently" );
    Header( "Location: http://www.new-url.com" );
    ?>

    But its redirecting only main domain, please help me how can i redirect posts too?

    Regards

  2. Scriptrunner (Doug Sparling)
    Member
    Posted 11 months ago #

  3. raadmunir
    Member
    Posted 11 months ago #

    Well dear i am not familiar with code and structure of .htaccess file. please can you make it for me?

  4. Scriptrunner (Doug Sparling)
    Member
    Posted 11 months ago #

    It'll depend on what web server your old site is using, but the easiest way to find out is to create a file:

    .htaccess

    and put it in the root of your web directory (on your old server).

    Just add this one line (replacing "new-site" with the domain of your actual new site):

    Redirect 301 / http://www.new-site.com/

    You can FTP the file up to your old server if need be, but check if your old server already has an .htaccess file (since it starts with a dot, it might be hidden from view).

  5. raadmunir
    Member
    Posted 11 months ago #

    i already have .htaccess file on old, so i place this code into that. Will this also redirect myolddomain.com/mypage.html to mynewdomain.com/mypage.html too? if i have same content and same permalink structure?

  6. Scriptrunner (Doug Sparling)
    Member
    Posted 11 months ago #

    No, but you should be able to use this (to the top of .htaccess file) if the page names and directory structure are identical, with the only difference being the domain name:

    RewriteEngine On
    
    # Redirect Entire Site to New Domain
    RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]
    RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]
  7. raadmunir
    Member
    Posted 11 months ago #

    No its still only redirecting to homepage of new domain instead of same page.

    Both sites are on same hosting.

  8. Scriptrunner (Doug Sparling)
    Member
    Posted 11 months ago #

    Did you remove this line?

    Redirect 301 / http://www.new-site.com/

  9. raadmunir
    Member
    Posted 11 months ago #

    i have just copy and pasted your given code on top of my .htaccess file nothing else.

    This line is not available Redirect 301 / http://www.new-site.com/

  10. raadmunir
    Member
    Posted 11 months ago #

    ok, i tried to do it using cpanel, its redirecting pages to but getting 404 error for posts/pages, on old site permalinks were /mypostpermailink/ and on new site permalinks are /mypostpermalink.html

    Any suggestion how to solve this?

  11. raadmunir
    Member
    Posted 11 months ago #

    still looking for solution?

Reply

You must log in to post.

About this Topic

Tags