Redirect everything from a certain url
-
I have a new domain (www.newdomain.com) and and an old domain (www.olddomain.com).
Currently both domains are pointing (via dns nameserves) at the new site. I want to 301 everything that comes from the www.oldsite.com to www.newsite.com.
I've used this htaccess code
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.newsite.com$
RewriteRule (.*) http://www.newsite.com/$1 [R=301,L]Which works fine and redirects if someone visits www.olddomain.com but I want it to cover everything from the old domain such as www.olddomain.com/archives/article1/ etc. So if any subpages etc are visited from the old domain its redirected to the new domain.
Could someone point me in the right direction?
Thanks
-
I'm not sure why you wouldn't want to send individual pages to the corresponding new ones on the new site.
But a really crude way to just point an entire old domain at a new one is to use "domain forwarding" - you'll set this up with whoever you manage the domain name with.
-
So which part shouldI remove - the RewriteCond or/and RewriteRule?
Thanks
-
Thanks, you are indeed right however in this case I need to redirect the old domain and all of its pages to the home page of the new.
I just need to know how to say if anything from www.olddomain.com INCLUDING sub pages and folders hits my site then redirect it to www.newsite.com. Both domain names are pointing at the same hosting.
Can anyone help?
-
Hi James, a question, do you want all the old pages simply to redirect to the new "home page" or do you have new versions of the old pages on your new domain? While I lack the detailed programming knowledge of Naghirniac; it seems to me that you should have a think about whether you want visitors who land on the old site's blue widget's page (assuming there is any traffic or link juice flowing in) to be redirected to a new version of blue widgets page on the new domain; rather than just a blanket transfer to the home page? If that's the case and you aren't talking thousands of pages then maybe redirects from each page would be worth thinking about?
Good luck anyhow!
-
Leave only the
RedirectMatch permanent /.* http://www.newdomain.com/take out the other part
-
Thanks tired that but I just get a error saying
This webpage has a redirect loop
-
You can use like this:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.newsite.com$
RewriteRule (.*) http://www.newsite.com/$1 [R=301,L]RedirectMatch permanent /.* http://www.newdomain.com/
-
Ok, how would I fit that into the above htacess code?
Thanks
-
Hi James,
I made some research, and there is several solutions, some depends on your Apache version. Try the rule above to see if it solve your problem:
RedirectMatch permanent /.* http://www.newdomain.com/
If not, you should take a look at http://stackoverflow.com/ The website has a lot of discussion on this theme.
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
-
Redirect 410
I used http status code as 410 for some low quality pages in my site to Redirect to homepage. is this useful to improve my homepage authority?
Technical SEO | | ghorbanimahan
my website is: Nitamoshaver.com0 -
Website redirects
We consolidated websites. All the international sites have been brought under the roof of our mothership site based in the US: www.crisisprevention.com ... We mapped out all of the URLs and where they should be redirected. However, if someone types in, say, www.crisisprevention.co.uk it redirects to the mothership site, BUT the old URL hangs around no matter what page you navigate to. I feel like it has duplicate content ramifications or worse. I would like opinions on this, so I can take my findings to IT and figure out a solution. Here’s another example: http://www.positive-options.co.uk and another http://www.positive-options.com
Technical SEO | | spackle0 -
301 redirects
Hello. Our site was recently rebuilt, and we switched from using index.php in all the urls to not using it at all. We also changed the names of many of our pages. So the urls have been renamed from "example.com/index.php/old_page_name/" to "example.com/new-page-name/". While we were at it, we changed from "_" to "-" as our word separators in the urls. In the .htaccess file, we have a small block of code that strips out "index.php/" from all requests. This code redirects a request for "example.com/index.php/old_page_name/" to "example.com/old_page_name/" For your information, the code that strips out "index.php/" is: RewriteCond %{THE_REQUEST} ^GET.index.php [NC]
Technical SEO | | nyc-seo
RewriteCond %{THE_REQUEST} !/uSZWTLna/.
RewriteRule (.?)index.php/(.*) /$1$2 [R=301,L] Then we have 301 redirects from "example.com/old_page_name/" to "example.com/new-page-name/" QUESTION 1: Is this two-step redirect approach okay, or would it be better to skip the separate index.php stripping code and simply have 301 redirects that include "index.php" in the urls? QUESTION 2: Will we lose some of the benefit of the links that have to pass through a 301 redirect? QUESTION 3: We have 50 or so redirects. Will this affect performance of the site? How many redirects does it take to start affecting performance? Thank you!0 -
301 redirect blog posts from old URL to new one
I moved a wordpress blog from domain.com to domain.com/blog . I want to redirect the links in google from the old domain.com to the new one, but I also want to put a new site/application at domain.com..so I'm thinking an .htaccess 301 redirect at the root wouldn't work. Any tips?
Technical SEO | | callmeed0 -
Temporary redirects
why is wordpress creating redirects from trackbacks and what can i do about it? according to seomoz i have several of these kinds of temporary redirects: http://redlandsorthodontics.com/about-us-2/meet-the-staff/redlands-orthodontics/trackback/ redirects to http://redlandsorthodontics.com/about-us-2 what are trackbacks anyway since i didn't purposely create them?
Technical SEO | | dad7more0 -
URL Rewrite
We are trying to convince a client to do a massive rewrite from all URL's looking like this: "www.company.com/category/categoryId=82374" to something like "www.company.com/womens/jackets/rain" How would you describe the importance and impact of doing URL rewrites to an ecommerce site? What evidence/research can we share with them to convince them it is worth the time and effort to do?
Technical SEO | | Hakkasan0 -
Redirecting a domain
I was setting up a new campaign and received the following error from Roger Robot. "We have detected that the domain www.sitename.com and the domain sitename.com both respond to web requests and do not redirect. Having two "twin" domains that both resolve forces them to battle for SERP positions, making your SEO efforts less effective. We suggest redirecting one, then entering the other here." I know about redirecting a PAGE using 301 Redirects and how to specify the www. canonical in Google webmaster tools, but is there a "DOMAIN" redirect that I'm missing. What would you suggest doing given the error message above. Thanks, Bill Sqnch.jpg
Technical SEO | | Marvo0 -
Is a 302 redirect the correct redirect from a root URL to a detail page?
Hi guys The widely followed SEO best practice is that 301 redirects should be used instead of 302 redirects when it is a permanent redirect that is required. Matt Cutts said last year that 302 redirects should "only" be used for temporary redirects. http://www.seomoz.org/blog/whiteboard-interview-googles-matt-cutts-on-redirects-trust-more For a site that I am looking at the SEO Moz Crawll Diagnostics tool lists as an issue that the URL / redirects to www.abc.com/Pages/default.aspx with a 302 redirect. On further searching I found that on a Google Support forum (http://www.google.com/support/forum/p/Webmasters/thread?tid=276539078ba67f48&hl=en) that a Google Employee had said "For what it's worth, a 302 redirect is the correct redirect from a root URL to a detail page (such as from "/" to "/sites/bursa/"). This is one of the few situations where a 302 redirect is preferred over a 301 redirect." Can anyone confirm if it is the case that "a 302 redirect is the correct redirect from a root URL to a detail page"? And if so why as I haven't found an explanation. If it is the correct best practice then should redirects of this nature be removed from displaying as issues in the SEO Moz Crawll Diagnostics tool Thanks for your help
Technical SEO | | CPU0