How can I redirect a browser to another page with a 301 or a 302 response using php?<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: <!-- m --><a class="postlink" href="http://www.newdomain.com/page.html">http://www.newdomain.com/page.html</a><!-- m -->");
exit();
?>
there ya goWhen I try that it seems to show up as just a redirect not a 301make sure it is like this, not what josh posted.
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: <!-- m --><a class="postlink" href="http://www.newdomain.com/page.html">http://www.newdomain.com/page.html</a><!-- m -->");
exit();
?>Oops, sorry, I just copied and pasted that from somewhere.yeah, there was a post here recently that had it.
and why would you worry about a 302? that is a normal found.302, is a redirect just as a 301. However its usually used locally. 301 is gone for good. 302 is resource moved... I beleive there are serveral others like resource moved to unknown location.Originally posted by scoutt
make sure it is like this, not what josh posted.
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: <!-- m --><a class="postlink" href="http://www.newdomain.com/page.html">http://www.newdomain.com/page.html</a><!-- m -->");
exit();
?>
I just had a domain change. I have a site that still link to the old domain. I don't want to ask the client again to access to his server. Will this PHP script take care of the problem that redirects the old link to the current domain? How effective for the spiders to follow to the current domain?I believe the spiders will follow it ok.
but you should get rid of your old domain cause when the DNS gets set it will no longer go there.Originally posted by scoutt
I believe the spiders will follow it ok.
but you should get rid of your old domain cause when the DNS gets set it will no longer go there.
I am not sure how to get my old domain. What should I do?Originally posted by SamH
PHP:
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: <!-- m --><a class="postlink" href="http://www.newdomain.com/page.html">http://www.newdomain.com/page.html</a><!-- m -->");
exit();
?>
What name should I save as? Do I need the Htacess file?
Do I do anything else to the server?Just save it as something .phpOriginally posted by SamH
I am not sure how to get my old domain. What should I do?
you go to the old domain and delete all the files. if DNS is not pointed theree anymore then there is no sense to leave them there. or have the old host delete the account
header("HTTP/1.1 301 Moved Permanently");
header("Location: <!-- m --><a class="postlink" href="http://www.newdomain.com/page.html">http://www.newdomain.com/page.html</a><!-- m -->");
exit();
?>
there ya goWhen I try that it seems to show up as just a redirect not a 301make sure it is like this, not what josh posted.
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: <!-- m --><a class="postlink" href="http://www.newdomain.com/page.html">http://www.newdomain.com/page.html</a><!-- m -->");
exit();
?>Oops, sorry, I just copied and pasted that from somewhere.yeah, there was a post here recently that had it.
and why would you worry about a 302? that is a normal found.302, is a redirect just as a 301. However its usually used locally. 301 is gone for good. 302 is resource moved... I beleive there are serveral others like resource moved to unknown location.Originally posted by scoutt
make sure it is like this, not what josh posted.
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: <!-- m --><a class="postlink" href="http://www.newdomain.com/page.html">http://www.newdomain.com/page.html</a><!-- m -->");
exit();
?>
I just had a domain change. I have a site that still link to the old domain. I don't want to ask the client again to access to his server. Will this PHP script take care of the problem that redirects the old link to the current domain? How effective for the spiders to follow to the current domain?I believe the spiders will follow it ok.
but you should get rid of your old domain cause when the DNS gets set it will no longer go there.Originally posted by scoutt
I believe the spiders will follow it ok.
but you should get rid of your old domain cause when the DNS gets set it will no longer go there.
I am not sure how to get my old domain. What should I do?Originally posted by SamH
PHP:
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: <!-- m --><a class="postlink" href="http://www.newdomain.com/page.html">http://www.newdomain.com/page.html</a><!-- m -->");
exit();
?>
What name should I save as? Do I need the Htacess file?
Do I do anything else to the server?Just save it as something .phpOriginally posted by SamH
I am not sure how to get my old domain. What should I do?
you go to the old domain and delete all the files. if DNS is not pointed theree anymore then there is no sense to leave them there. or have the old host delete the account