I have the domain www.oldsite.com and i set a redirect to forward to www.newsite.com/new
but when i google search old site all of its sub links go to www.newsite.com/new/sublink
How do i edit the htaccess file so that the sub links never pass though
RewriteCond %{HTTP_HOST} ^oldsite\.com*$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com*$
RewriteRule ^/?$ "http\:\/\/www\.newsite\.com\/new" [R=301,L]
In short all links involved in oldsite.com should redirect to newsite.com/new
I read the below but it didnt seem to help to much. htaccess: domain hosted on subdirectory
The below .htaccess
should be place on the root folder of the old domain only:
RewriteCond %{HTTP_HOST} ^(www\.)?oldsite\.com$ [NC]
RewriteRule ^ http://www.newsite.com/new [R=301,L]
It will redirect anything from the old domain to the new one, for example:
http://oldsite.com/someurl
Will go to:
http://www.newsite.com/new
No URLs from the old site will be passed down to the new site, they will all be sent to /new
.
NOTE: make sure you do not have any additional .htaccess
files in other folders of the old domain as those will set null the previous rules.
If you want to send only the main domain to the new one without any URLs within:
RewriteCond %{HTTP_HOST} ^(www\.)?oldsite\.com$ [NC]
RewriteRule ^/?$ http://www.newsite.com/new [R=301,L]
A different way would be to handle all the URLs on the new site, which would be like the below .htaccess
:
RewriteCond %{HTTP_HOST} ^(www\.)?oldsite\.com$ [NC]
RewriteRule ^ http://www.newsite.com/new%{REQUEST_URI} [R=301,L]
It will redirect anything from the old domain to the new one, for example:
http://oldsite.com/someurl
Will go to:
http://www.newsite.com/new/someurl
If you do not wish the new to show up simple remove /new
from the rule above.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.