301 domain name to another site
-
I had 2 websites. I decided not to maintain one of them and set it to 301 to my main website. However, i see people getting 404 errors when they land on my main website but with a page name from the old site. How can I set things so that anyone who tries to go to the old site goes to my homepage of my main site?
http://oldsiteB.com/oldpagename sends them to http://siteA.com//oldpagename = 404 - I want them to go directly to homepage on siteA.
-
Try to put that .htaccess on the old site. It will rewrite the asked URL before it can be processed by the server. It will rewrite the request to contain the new domain.
On the new domain, you already have the code to process these requests.
Try that and report back. It probably works after that.
-
No, I put it on the .htaccess on the new site. I had 301'd the whole old site in my domain name manager. Maybe I should not do that so I can put an .htaccess file right on the old domain?
-
Ok, just to be sure: you have placed this .htaccess on the old site. Right?
If that is the case and you've pasted the exact code i mentioned, then something else might be causing the issue.
Also: be sure to try this with a browser that hasn't visited the site in a while. It happens to me sometimes that the browser will simply remember the redirect and not follow the .htaccess.
Hope any of this helps!
-
Actually, I tried that, and the result is still
Old URL: "www.myoldsite.com/my-page/"
New URL: "www.mynewsite.com/404.html -
Yes, that helps, thank you!
-
Ok so i had to test this one because i wasn't sure but you would have to remove "$1" from the last line.
That piece actually will add the file path of the original domain and add it to the domain you are redirecting the visitor to.
So this "www.myoldsite.com/my-page/"
Will become "www.mynewsite.com/my-page/"Since you want it this way:
Old URL: "www.myoldsite.com/my-page/"
New URL: "www.mynewsite.com/"Removing the "$1" should do the trick.
Is this an answer to your question?
Bas
-
Can I use this option and somehow direct all traffic from old site to my new home page? I tried this and if someone was trying to find a specific page on the old site they get a 404 on the new.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^OLDSITE.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.OLDSITE.com [NC]
RewriteRule ^(.*)$ http://NEWSITE/$1 [L,R=301,NC] -
Hi,
You have 2 methods that i would use:
Method #1: using .htaccess
Option A: redirect one specific URL to a new specific URL:
Redirect 301 /old/old.html http://NEWSITE/new.htmlNote: 'old/old.html' has to be without the domain name: so just the directory + page.
Option B: redirect an entire directory to a new specific URL:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^OLDSITE.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.OLDSITE.com [NC]
RewriteRule ^(.*)$ http://NEWSITE/$1 [L,R=301,NC]Note: the second line of that example has to be without 'www'.
Method #2: using PHP
If you have one header-file, you can place this code in the top of that php-file:
header( "Status: 301 Moved Permanently" ); header( "Location: http://NEWSITE" ); exit(0); ?>Would that provide an answer for you?
Yours,
Bas
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Spammers created bad links to old hacked domain, now redirected to our new domain. Advice?
My client had an old site hacked (let's call it "myolddomain.com") and the hackers created many links in other hacked sites with links such as http://myolddomain.com/styless.asp?jordan-12-taxi-kids-cheap-T8927.html The old myolddomain.com site was redirected to a different new site since then, but we still see over a thousand spam links showing up in the new site's Search Console 404 crawl errors report. Also, using the links: operator in google search, we see many results of spam links. Should we be worried about these bad links pointing to our old site and redirecting to 404s on the new site? What is the best recommendation to clean them up? Ignore? 410s? Other? I'm seeing conflicting advice out there. The old site is hosted by the client's previous web developer who doesn't want to clean anything up on their end without an ongoing hosting contract. So beyond turning redirects on or off, the client doesn't want to pay for any additional hosting. So we don't have much control over anything related to "myolddomain.com". 😞 Thanks in advance for any assistance!
Technical SEO | | usDragons0 -
Treatment of domain names in content that are not actually a link
From PR activity we've found that lots of newspaper sites will include reference to a domain name in an article but not actually make this a link through to the domain. For example we will see text like: For further information read the full report at www.bluewidget.com Of course we make attempts to contact the newspaper to request they make it a link but this doesn't always achieve a result. So the question is, does Google place any value for the identified domain in a case like this?
Technical SEO | | bjalc20110 -
Using images from one domain on another?
I run a travel photography business where I sell fine art prints. I've been toying with the idea of creating a few new websites about some of the places I've traveled to. This is for a few reasons. First, because I love talking about my travels. But second, because I feel like it might be a good way to bring in more print sales from those places. The question I have, if I were to use the images from my main photography sales domain on a different domain, how does this affect SEO? These images filenames for the photographs are already optimized well for searching. Thanks!
Technical SEO | | shannmg10 -
Domain vs Sub Domain and Rankings
Hi All Wanting some advice. I have a client which has a number of individual centres that are part of an umbrella organisation. Each individual centre has its own web site and some of these sites have similar (not duplicate content) products and services. Currently the individual centres are sub domains of the umbrella organisation. i.e. Umbrella organisation www.organisation.org.au Individual centres are sub domains i.e. www.centre1.organisation.org.au, www.centre2.organisation.org.au etc. I'm feeling that perhaps this setup might be affecting the rankings of the individual sites because they are sub domains. Would love to hear some thoughts or experience on this and whether its worth going through the process of migrating the individual centre domains. Thanks Ian
Technical SEO | | iragless0 -
Local site under generic domain
Howdy Mozers, We have main website on .com domain and local websites for each language like .es, .fr, .in etc. We decided to move all local sites under main domain .com using subdirectories with gTLDs. One of the local sites has a manual penalty. Right now we are redirecting local site which have penalty using 302 redirect. So my question is. Will 302 redirect hurt our main site? Is there any other way to redirect visitors from local site without passing penalty? We have few thousands monthly users who are still using local domain links to get to our site, so we can't remove redirect at all. Best Regards,
Technical SEO | | juris_l
Juris0 -
Domain Name appear as title no description in search result
Hello Everyone, I have an site suppose tatadocomo.com( imaginary name to just explain my query) .Two weeksa back everything was fine but now if i search any query that site ranks in SERPs I got domain name as title and url (homepage) beneath of title and after that 'click here to proceed'. .Tata Docomo tatadocomo.com Click here to Proceed Why I am seeing this result in SERPs? I checked robots.txt , everything is fine there. Please help me out. Thanks
Technical SEO | | Alick3000 -
Will bad things happen if I cancel 301 site redirect?
Hi, please someone help! We have two identical websites, say A & B. Because of the not so good SEO establishment, site B was built and site A was 301 redirected to site B weeks ago. For some reasons, we have to reuse site A, which means we have to cancel the 301 redirection. (Sound a little crazy) So the question are: 1. Can we conduct the action? 2. If we cant, what's the reason? 3. If we can, what would be the best practice? Thanks for help in advance! Plus: we also CARE what would happen to site B if the 301 is cancelled? Will it grow healthy like a new site?
Technical SEO | | Squall3150 -
I grabbed a better domain name. What next?
I have been trying to rank well for the key word "National Currency" forever and can't seem to make it into the top ten. I would really like to have the URL NationalCurrency but it's taken and can't be bought. My url is nationalcurrencyvalues. After reading the forums and various other SEO advice it occurred to me that National-Currency is as good or better than NationalCurrency for that keyword because it's seen as two words. (right) So, I grabbed that domain name. Now, my question... is there some way to make use of the National-Currency domain name without building an entirely new site? I don't think I want transfer all of my content from nationalcurrencyvalues. Would there be any benefit to my nationalcurrencyvalues if I set up 303's on National-Currency?
Technical SEO | | Banknotes0