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
-
Is there an easy way to hide one of your URL's on google search?, rather than redirecting?
We don't want to redirect to a different page, as some people still use it, we just don't want it to appear in search
Technical SEO | | TheIDCo0 -
SSL redirect issue
Hi guys, I have a site that has some internal pages with SSL. Recently i noticed that if i put https://mydomain.com, this URL is accessible but all the design is messed up. My site is on wordpress and i use "redirection" plugin for all the 301 redirect. So i decided to add a new 301 redirect from https://mydomain.com to my actual URL version of home page http://mydomain.com. After doing that, my home page doesn't load at all. Does anybody know what happens? Thank you for advice!
Technical SEO | | odmsoft0 -
Redirecting 301 or 302?
Hi, I think the part of this question has been already discussed, but not exactly the same, I think. My site requires authentication for member page. When a user try to go to member area, we redirect to 3rd party to do the authentication. 1. user clicks a link to www.mysite.com/member/contents.html
Technical SEO | | HypermediaSystems
2. www.myauthenticate.com/login?h=somehashuniquehash454859428778545 (enters id/pass)
3. login success => redirect back to www.mysite.com/member/contents.html We are doing it 302, temporary redirect. But moz crawler error seems to suggest we should do it 301.
So my question is:
A. Should we do it 301???
B. If we do 301, what happens to myauthenticate.com? since it has hashtag, I am afraid it could create a lot of duplicate contents on myauthenticate.com side... Thank you so much for your help in advance...0 -
Importance of 301 Redirects
Hello, I have been brought in at the last minute to consult for an e-commerce client who is about to relaunch their website. The site currently receives 8000 visits a month, 3100 of which are from organic search. They have a few thousand product pages. The web development firm they are using is changing all of the old product page urls and using 'search engine friendly' urls for the new site, which is expected to launch in a few weeks. However, they did not/are not planning on including 301 redirects from the old URLs. Other than simply stating 'this will be bad for your SEO', what would be a correct way of explaining to the client how much of a problem it will be if their new site launches without 301s. For example, is this a big enough issue to delay the launch of the site / get in a contract dispute with the web developer?
Technical SEO | | stageagent0 -
Magento Redirect Loop
On my clients site I changed the URL structure for products. First they had a trailing slash: http://www.wellamy.com/market/food/oklahoma-relief-effort/healthy-snacks/caramel-apple-chewy-snack-bars/ I changed it to end in .html http://www.wellamy.com/market/food/oklahoma-relief-effort/healthy-snacks/caramel-apple-chewy-snack-bars.html Now rather than redirecting properly, it causes a redirect loop. Any idea how I can fix this?
Technical SEO | | Imajery0 -
Rebranding / Redirecting
Hi I have a client who wants to re-brand their shopify clothing store under new domain name. Whilst still a clothing store its going to have different department structure and product pages and will hence be a different store/site. Is there anyway to pass any of the history/authority of existing site to the new one such as 301 redirecting the top level pages of existing site to nearest equivalent pages of new site etc or best to just redirect the old site domain to the new ? Cheers Dan
Technical SEO | | Dan-Lawrence0 -
What tools produce a complete list of all URLs for 301 redirects?
I am project managing the rebuild of a major corporate website and need to set up 301 redirects from the old pages to the new ones. The problem is that the old site sits on multiple CMS platforms so there is no way I can get a list of pages from the old CMS. Is there a good tool out there that will crawl through all the sites and produce a nice spreadsheet with all the URLs on it? Somebody mentioned Xenu but I have never used it. Any recommendations? Thanks -Adrian
Technical SEO | | Adrian_Kingwell0 -
Wordpress URL weirdness - why is google registering non-pretty URLS?
I've noticed in my stats that google is indexing some non-pretty URLs from my wordpress-based blog.
Technical SEO | | peterdbaron
For instance, this URL is appearing google search: http://www.admissionsquest.com/onboardingschools/index.php?p=439 It should be: http://www.admissionsquest.com/onboardingschools/2009/01/do-american-boarding-schools-face-growing-international-competition.html Last week I added the plugin Redirection in order to consolidate categories & tags. Any chance that this has something to do with it? Recs on how to solve this? Fyi - I've been using pretty URLS with wordpress from the very beginning and this is the first time that I've seen this issue. Thanks in advance for your help!0