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.
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
-
Canonical URL Change
Hi, I have a Product Page, say www.example.com/product-title/.
Technical SEO | | viatrading1
Canonical URL is www.example.com/product-title/ I want to change its URL to www.example.com/product-title-2/
Canonical URL is www.example.com/product-title-2/
Can't do 301 Redirect. Is SEO Juice passed from www.example.com/product-title/ to www.example.com/product-title-2/ ? Thanks,0 -
Which URL is better?
Hi everyone, Could you please help me with picking out the right URL for my company's website? We are MoonCreate and we make beautiful clothes. Unfortunately, the domain mooncreate.com is not available and I have to choose between mooncreatebrand.com or mooncreatewear.com Which one is better, in your opinion? Look forward to receive your suggestions! Thank you! 🙂
Technical SEO | | kirupa0 -
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 -
Redirecting http to https, do I need to add new url to webaster tools?
Hey all, we just 301 redirected all our http url's to https. I'm getting some funky data in webmaster tools, such as a drastic change in pages indexed and pages submitted over pages indexed. Might be a dumb question, but do I need to update my website in webmaster tools with the new https address, or should I be getting credible data from the old http url that is already in there? Thank you in advance!
Technical SEO | | jaychow0 -
Marketing URL
Hi, I need a bit of advice on marketing URL's. The destinations URL is http://www.website.com/by-development.php?area=Isle Of Wight&development=developmentname. If we wanted to use www.website.com/developmentname on literature to send people to the ugly URL above, what would we do? Would we need to rewrite the ugly URL to the neat and then 301 the ugly to the neat? Currently, the team are using a new domain of neatandrelevant.info and 301 redirecting it to ugly URL but there are lots of different developments they want to send people to so a new domain is bought for each development which seems a bit unnecessary. They point to different pages on the ugly URL website. Assuming canonical tag would not be needed then because the ugly URL page would be redirected. Also, as the website has ugly URL's anyway, would it not be best practice to use rewrites anyway so that the URL's read www.mywebsite.com/region/development? Would it confuse things to then have extra short marketing URL's missing out /region? Hope that makes sense....
Technical SEO | | Houses0 -
Friendly URL
Can be Friendly URL installed on a custom made jobsite using mod rewrite / apache without any big interference to the system itself? Thank you.
Technical SEO | | tomaz770 -
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 -
Query String Redirection
In PHP, I'm wanting to store a session variable based upon a link that's clicked. I'm wanting to avoid query strings on pages that have content. My current workaround is to have a link with query strings to a php file that does nothing but snags the variables via $_GET, stores them into $_SESSION, and then redirects. For example, consider this script, that I have set up to force to a mobile version. Accessed via something like a href="forcemobile.php?url=(the current filename)" session_start(); //Location of vertstudios file on your localhost. Include trailing slash $loc = "http://localhost/web/vertstudios/"; //If GET variable not defined, this page is being accessed directly. //In that case, force to 404 page. Same case for if mobile session variable //not defined. if(!(isset($_GET["url"]) && isset($_SESSION["mobile"]))){ header("Location: http://www.vertstudios.com/404.php"); exit(); } //Snag the URL $url = $_GET["url"]; //Set the mobile session to true, and redirect to specified URL $_SESSION["mobile"] = true;header("Location: " . $loc . $url); ?> Will this circumvent the issue caused by using query strings?
Technical SEO | | JoeQuery0