Redirect 301 after domain change - redirect

I had to do a domain change on a website so I moved from www.mydomain.it to www.mydomain.eu. At the moment I don't have full control on the .it domain so when it was the time to make the domain change I asked the hosting provider to make a 301 redirect of the .it to the .eu so as a result, I got all the pages of the .it website redirected to my .eu's homepage (no 404 errors) because the previous website used queries as pages' URLs.
This is a link example of the previous website:
http://www.mydomain.it/index.php?page=lkr_pg_chisiamo
So what I started getting after the redirect was:
https://www.mydomain.eu/index.php?page=lkr_pg_chisiamo
which gave me back the homepage content as a result and not a 404 error.
The old website had at least 10k links like that one so each of them started having the behavior of the link above, I got the homepage content for all links. In the beginning, I thought it was a good thing for me because I wasn't getting 404 errors but then I started digging around on the web and I found out to not be a good practice because all links might be recognized as soft 404 errors.
Obviously before I made the domain change I had created all the 301 redirects of the most important pages of the website like this:
RewriteCond %{QUERY_STRING} ^page=lkr_pg_chisiamo$
RewriteRule ^(.*)$ https://www.mydomain.eu/chi-siamo/? [R=301,L]
RewriteCond %{QUERY_STRING} ^page=lkr_pg_contattaci&form_key=25-8124355$
RewriteRule ^(.*)$ https://www.mydomain.eu/contatti/? [R=301,L]
And so on..
Obviously, I didn't do that for all the 10k pages, but just the most important, so the other links are still pointing to the homepage content.
After I did this, I told Google I had changed the domain through the Google Search Console.
After a few weeks, I started seeing some results on Google but after one month I'm not still happy with them, I think I lost rank on Google. I know it could take a while more to do everything and that I should probably lose 3% of my "domain juice" after a domain change but what I was wondering if I have done everything in the right way in order to not lose rank.
My concern now is about all the links that I wasn't able to redirect and that has been redirected automatically and started getting the homepage content. Should I be worried about them?
How should I manage them?
Should I redirect them to another page which is not the homepage?
If yes, is there a way to redirect all those links (just those) even though I have all the other redirects in my .htaccess file?
Was there a better way to redirect all the 10k links of that type? How would I be able to do that?

You asked this 6 months ago, but i hope i can help you.
Add this to your .htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^mydomain\.it$ [NC]
RewriteRule ^(.*)$ http://mydomain.eu [R=301,L]
This should redirect all links to your new domain.
About Google Search Console, take a look here: https://support.google.com/webmasters/answer/93633?hl=en
About changing domain, look at: https://support.google.com/webmasters/answer/6033049?hl=en
Hope this helps!
Brhaka

Related

Setting Up a Redirection from domain.com to www.domain.com

I have a website. At this time, I can access this website if I visit http://www.example.com and http://example.com. When I run some validation tests, I get the following error:
There is duplicate content on http://www.example.com and http://example.com. This is bad, as technically they are classed as two different websites. Search engines may lower a website's rank if they find the same content on two different URLs.
Choose one domain that you would like to use and then set a permanent (HTTP 301) redirect to forward users who visit the other.
My question is, how exactly do I fix this? Do I update the CNAME records? I don't fully understand how this mapping happens or why the addresses are even different.
I hope this works for you:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301,NC]
You need to add this in your .htaccess file

How to stop Facebook crawler from following 301 redirect in .htaccess?

I am in the final stage of updating a website and changed many url's for SEO purposes. Now I want to keep the social scores for most pages, most importantly the Facebook likes and comments. It has been confirmed that this is possible. See the following link for reference: How can I move a URL via 301 redirect and retain the page's Facebook likes and Open Graph information?
og:url on newurl.html page should be oldurl.html -> done
keep valid page with old og tags named oldurl.html -> done
redirect from oldurl.html to newurl.html -> done
exempt the Facebook crawler from this redirect -> I don't know how
I can't find an answer on how to this and there have been other people asking the same question with no answer. Only got purple links left on this subject and do not know what to do or search anymore.
How do does one stop a crawler from following a redirect?
Edit. I know now that this won't work this way but it is the best I can do. One of the conditions being don't be Facebook and then all the rules bundled together for that condition without having to repeat the condition for every rule:
RewriteCond %{HTTP_USER_AGENT} !facebookexternalhit/[0-9]
RewriteCond %{HTTP_HOST} ^$
RewriteRule ^old-url1\.html$ http://domain.com/new-folder/new-url1.html? [N,R=301]
RewriteRule ^old-url2\.html$ http://domain.com/new-folder/new-url2.html? [N,R=301]
RewriteRule ^old-url3\.html$ http://domain.com/new-folder/new-url3.html? [L,R=301]
Edit2. I'll have to go with the repeat for every rule. Many url's changed name. Something more elegant might be possible but that is way beyond my ability. Does it have a significant influence on page load time if the code below is repeated 60 times with different url's?
RewriteCond %{HTTP_USER_AGENT} !facebookexternalhit/[0-9]
RewriteRule ^old-url1\.html$ http://domain.com/new-folder/new-url1.html? [L,R=301]

Redirect all posts on wordpress

I moved my site to a new host but by accident permalink was changed. First i had a /%postname%.html and after moving to new host it got changed to /%postname%/ .
I fixed the permalink and is working fine except when Google crawls my website google search results return 404 error pages.
I tried every redirect plugin and nothing is working. I want to redirect every post that is http://www.website.com/sample-post/ to http://www.website.com/sample-post.html
I can not add every single post because there are around 100k posts.
Any ideas?
thanks
Firstly you are attempting to treat the symptom, not the problem. This will cause more issues for you in the future.
However, the best way to do what you want is to use rewrite rules in apache's .htaccess file.
Something like this should work. Modify as desired.
# add .html file extension
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.+)$ /$1.html [L]

htaccess rewrite one file type with get variables

i think header is confusing, here is the situation.
i host some video files and want to use on my website. but only on my website. if you realized facebook did this. but we dont have servers like them -nginx i guess-.
finally i want to redirect all requests to a certain page. like that
if someone request that
http://www.blabla.com/videos/1.mpg?hash=12345&expire=1234567
htaccess redirect that request to
http://www.blabla.com/check.php?file=videos/1.mpg&hash=12345&expire=1234567
but also if someone type
http://www.blabla.com/videos/1.mpg
it is also redirect to check.php
http://www.blabla.com/check.php?file=videos/1.mpg
RewriteCond %{QUERY_STRING} ^hash=(.*)$
RewriteRule ^(.*)/videos/(.*)$ /check.php?file=videos/$2 [R=302,L,QSA]
Now your rewriteRule will only be applied if query string contains hash=xxxxx
use R=301 if you want users to be redirected permanently

Sitewide 301 Redirect

I am looking to perform a sitewide 301 redirect. The original site is over 15 years old! I understand the concept of making the .htaccess file with the code:
redirect 301 "/old/old.htm" http://www.you.com/new.html
However will this redirect every page of the old site? or just an individual page. How do I achieve redirection with the entire site?
I have a rewrite in .htaccess (apache rewrite mod enabled), all pages from old site
http://www.old.com and
http://www.old.com/site/index.php? .... redirect to the new site
http://www.new.com or
http://www.new.com/website/index.php?... (notice that /site/ and /website/ are different names)
pages from the old site
https://www.old.com (notice the s on https://) get redirected fine but pages from
https://www.old.com/site/index.php?... do not, they get a 404 error
since the old site is not secure anymore neither the
https://www.old.com or
https://www.old.com/site/index.php?... really exist anymore but
https://www.old.com gets redirected and the ones with
/site/index.php?... added do not get redirected but go instead to a 404 error
Be careful with a 301, 301 redirect is used for where content has moved.
e.g. content about making a cake was here /makeacake.html now is /cakes/making-a-cake.html.
what I would recommend is find the pages where the majority of your uses come to, and redirect those pages to the new relevant pages / sections and just delete the rest and add a custom 404 error page. which tells them the old content has been moved.
You can also use goggle web masters to remove pages from there index.
Assuming the old pages don't exist any more (would throw 404-errors), you can do the following: You redirect all the pages that don't exist anymore to the start page. (As specified in the comments below.)
This is the updated .htaccess code you can use to make that happen. The first RewriteCond checks if the requested path is a file, the second checks if its a directory. After that, you get redirected to the startpage - or any other page for that matter.
http://www.example.com/i/am/an/old/page.html or http://www.example.com/i/am/a/different/old/page.html will all redirect to http://www.example.com/
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . / [R=301,L]
The best way to redirect the entire site is by doing domain forwarding through your web server (or web host... most have the option in their control panel).
Domain forwarding is much more efficient than sending 301 redirects back to the client.
Am I right in thinking that your site is on the same domain name but you've changed it structurally?
So, you have a load of old page URLs that have now changed to new URLs (but on the same domain).
For example, you may have had:
www.yourdomain.com/about-us/history.htm
that has now become
www.yourdomain.com/our-history.htm
If that is the case you will more than likely need to set up many 301 redirect rules. It doesn't necessarily mean that you have to set up one rule for every single page change as you can use RegEx to catch pattern changes in the URL structure. As a scale example, I recently set up a htaccess file of 301 redirects for a site with just under 600 changed URLs. There were 70-something 301 Redirect rules in the end.
It's not necessarily a small job but it is doable. Worth it to retain your SEO rankings.