Best Way to Redirect 301 (11 posts)

  1. raadmunir
    Posted 1 year ago #


    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?


  2. raadmunir
    Posted 1 year ago #

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

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


    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).

  4. raadmunir
    Posted 1 year 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?

  5. 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]
  6. raadmunir
    Posted 1 year ago #

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

    Both sites are on same hosting.

  7. Did you remove this line?

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

  8. raadmunir
    Posted 1 year 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/

  9. raadmunir
    Posted 1 year 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?

  10. raadmunir
    Posted 1 year ago #

    still looking for solution?

Topic Closed

This topic has been closed to new replies.

About this Topic