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 ?
15 September 2009 at 14:20
.htaccess file and paste this:
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
Better, faster, clearner 🙂
15 September 2009 at 14:23
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:
15 September 2009 at 14:24
Gah, sorry, was writing the former comment before Ionut posted his.
15 September 2009 at 23:18
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
16 September 2009 at 02:55
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?
9 November 2009 at 09:01
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.
9 November 2009 at 14:19
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