How to redirect a blog to another blog

So you have to redirect something that has 100K of files to a new site
how can you do it:

this snippet of code I’ve use it for a wordpress website, just insert the following code in the index.php in the root folder

header(“HTTP/1.0 301 Moved Permanently“);
$page = $_SERVER[‘REQUEST_URI‘];
header(“Location: http://thewewpage.com$page”);

example: http://example.com/index.php?arg=2&arg=3
will redirect to http://thenewpage.com/index.php?arg=2&arg=3

cute no ?

7 Comments

  1. .htaccess file and paste this:

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

    Better, faster, clearner 🙂

  2. Wouldn’t it be easier just to do it via .htaccess? In that case you could redirect even an empty folder or subdomain without the need for it to first load the index page.

    Oh, and the code is:

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

  3. Gah, sorry, was writing the former comment before Ionut posted his.

  4. 2 is better than one 🙂

    anyway, i’ve gone for php because on different shared servers is .htaccess is off and it’s the most simple way for WP

  5. Yeah but wouldn’t that mean that if someone for example is accesing a folder that doesn’t contain the index.php file will not get redirected?

  6. I have One issue, please help me. My issue is I have url http://subdomain.mydomain.com and want to redirect them http://mydomin.com/folder1/index.php?user=subdomain. but I dont want to change URL in addressbar so in addressbar the url should be http://subdomain.mydomain.com. What i have to do? My .htaccess code is
    =================================
    #RewriteCond %{HTTP_HOST} !^www\.mydomain.com [NC]
    #RewriteCond %{HTTP_HOST} ([^.]+)\.mydomain.com [NC]
    #RewriteRule ^(.*)$ http://mydomain.com/folder1/index.php?user=%1 [L]
    =================================
    It redirect correctly, But Unfortunitly, it affect addressbar, so it’s useless for me. Please help me. What I have to do? Thanks in advance.

  7. ah, the joy of wilcard, the thing is, you can use a iframe 100% wide but, i have no idea how to make them redirect to the frame without changing the url

Leave a Reply

Your email address will not be published. Required fields are marked *