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 Error
Hello, I was sent a report from a colleague containing redirect errors: The link to "http://www.xxxx.com/old-page/" has resulted in HTTP redirection to "http://www.xxxx.com/new-page".Search engines can only pass page rankings and other relevant data through a single redirection hop. Using unnecessary redirects can have a negative impact on page ranking. Our site is host on Microsoft Servers (IIS). I'm not sure what is causing these errors. Would it be the way the redirect was implemented.
Technical SEO | | 3mobileIreland0 -
I have a sub domain that has live content on it but the root domain redirects to another URL. I know this is not great but what are the implications?
I have a subdomain that is populated and has content. The root domain that the sub lives on redirects to an entirely different URL. I am trying to make a case as to why this isn't great besides the fact that it is just weird user experiences. What are the SEO implications etc. Would any equity that gets built up on the subdomain get passed along in the redirect? Or will there be indexation issues with Google? Cheers, Mark
Technical SEO | | mjsikorsky0 -
Should I make a new URL just so it can include a target keyword, then 301 redirect the old URL?
This is for an ecommerce site, and the company I'm working with has started selling a new line of products they want to promote.Should I make a new URL just so it can include a target keyword, then 301 redirect the old URL? One of my concerns is losing a little bit of link value from redirecting. Thank you for reading!
Technical SEO | | DA20130 -
Should I change a 301 redirect?
I recently moved all the content from an old site to a new site on a new domain. I lost a significant amount of traffic as a result. There are 301 redirects for every page on the old site. Generally, these point to the same content as was on the relevant page of the old site. However, the 301 redirect for the homepage on the old site points to the homepage on the new site, not to the content from the old site homepage. I'm wondering whether to change the 301 to point at the content from the old site homepage. Any advice would be much appreciated.
Technical SEO | | seqal0 -
Shorter URLs
Hi Is there a real value in having the keywords in the URL structure? we could use the URL: Mybrand.com/software/tablets/ipad/supertrader.html Or instead have the CMS create the shorter version mybrand.com/supertrader.html and just optimize this page for the keyword 'supertrader ipad software'
Technical SEO | | FXDD1 -
Redirection in two phases
Hi, One of my client want a website revamp in two phases. The first phase would be to move the CMS from Sharepoint to Drupal keeping the same content and URLs but the page extension will change (it could become php or just the name of the page without any extension) The second phase will be a content revamp with URL change. The first phase will last 3 weeks and then we will push the second phase with the new content and the new URL. Some shortcuts to make it a more readable: old url = OURL old url with new extension = OURLEX new URL = NURL My problem is how can I manage the redirections. Should I: Phase 1: create one rule that will redirect all the OURL to the OURLEX Phase 2: keep the rule I created in phase 1 and add rules for OURLEX to NURL Or Phase 1: create one rule that will redirect all the OURL to the OURLEX Phase 2: keep the rule I created in phase 1 and add redirect OURL to NURL Or Phase 1: create one rule that will redirect all the OURL to the OURLEX Phase 2: remove the rule I created in phase 1 and add redirect OURL to NURL Or Phase 1: create a rules for each OURL that will redirect all the pages to OURLEX Phase 2: remove the rules I created in phase 1 and redirect the OURL to NURL Or Phase 1: create a rules for each OURL that will redirect all the pages to the OURLEX Phase 2: keep the rules I created in phase 1 and add rules to redirect the OURLEX to the NURL Or something else you think is better Difficult to explain, let me know if it's understandable. Thanks for you help! GaB
Technical SEO | | Pherogab0 -
301 redirect issues
Hi all, I'm hoping someone will be able to help me with an extermley frustrating problem with 301 redirects in .htaccess. Basically I'm trying to redirect some old pages (from our old website) that stil rank to the new equivilent. For example - old url = www.domain.com/frames/news/company-news/news-reader.php?newsStoryID=395 New www.domain.com/news/article-title I've tried the simple redirect 301 /frames/news/company-news/news-reader.php?newsStoryID=395 http://www.domain.com/news/article-title But this doesnt work. I've also tried - RewriteEngine on
Technical SEO | | EclipseLegal
RewriteCond %{QUERY_STRING} ^newsStoryID=395$
RewriteRule ^/news-reader.php$ http://www.domain.com/news/article-title/? [L,R=301] Could anyone help? I've followed lots of tutorials that all match the above but it just doesn't work! The only other thing within the htaccess file is from wordpress for pretty permalinks - BEGIN WordPress <ifmodule mod_rewrite.c="">RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]</ifmodule> END WordPress Many thanks in advance!0 -
HTML url extension
I've read some information about the extension of an url. But i couldn't find a clear answer. What is better for SEO, an extension with html or without? /make-money-online/how-to-make-a-million-dollars-in-1-year/ or /make-money-online/how-to-make-a-million-dollars-in-1-year.html/ Is there a difference between a normal website or a blog?
Technical SEO | | PlusPort0