My site url is www.testing.com
and there is another site www.testing.com/newsite
.
I want everyone who hits www.testing.com/newsite
to be redirected to www.newsite.com
My site url is www.testing.com
and there is another site www.testing.com/newsite
.
I want everyone who hits www.testing.com/newsite
to be redirected to www.newsite.com
So simply add below line at index page.
header("Location: http://www.testing.com", false, 301);
exit;
Or write it in common file that are included in every page.
make sure there is http://
in header location other wise it will look for directory.
And also put exit;
at the end so other code will not execute.
because sending header will not terminate script execution.
--EDIT-- it should be 301 to make it last forever
If you have a directory /newsite
then place a .htaccess
inside that directory with:
RewriteEngine On
RewriteRule ^.*$ http://www.newsite.com/ [R=301,L]
However if you directed the newsite.com
into the /newsite
directory, then you need what Sankalp Mishra wrote in his answer. (but with newsite instead of testing)
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^newsite$ http://www.newsite.com/ [R=301,L]
Write header like:
header("Location: http://www.testing.com");
on the home page of http://www.testing.com/newsite
for more about header
Use this in htaccess
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^newsite.*$ http://www.testing.com/ [R=301,L]