Typo3 switch to default domain - typo3

In typo3 in the list view I have added two url records. The first one (on top) is www.domain.com and the second one is domain.com. When you now go directly to domain.com the webpage is opened under that url. But I want it to switch to www.domain.com and then op the home page.
How is it possible in typo3 that the url is always switched to the top urls, www.domain.com in this case?

I handle this as such in .htaccess:
Then you either don't need the domain records at all in TYPO3 (if the installation only has one site/domain) or just the www one.
RewriteEngine On
# * FORCE WWW *
# -----------------
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]
That solution is quite robust and non-www-addresses never show up in google.
Be careful if you have running subdomains like something.example.com though, this might need an advanced .htaccess rule.

Yes, it is possible. Just edit the record for the non-default domain and set the field "Redirect To" and the status code for the redirect.
You may not see these fields initially, if so, either check the checkbox "Show secondary options (palettes)" at the bottom of the page, or click the small "more options" icon directly under the domain field.
If you have many domains, this becomes impractical. In that case, consider doing the redirect directly in the webserver configuration. That would also be more performant (as TYPO3 isn't even started up to do the redirect).

Related

Redirect 301 after domain change

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

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

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

mod_rewrite - which hosting account to redirect to?

Let's say we have two domains www.mydomain.com and www.mydomain.co.uk
Our main site is on www.mydomain.com
We have a separate hosting account, on the same server, for www.mydomain.co.uk - all this does is have an .htaccess file which redirects to mydomain.com
[CODE]
RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^.:]+\.)*mydomain\.co.uk\.?(:[0-9]*)?$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/?referrer=mydomain.co.uk
[R=301,L]
[/CODE]
We also have set up a blog, on www.mydomain.com/blog/
PROBLEM: We also want the subdomain:
http://blog.mydomain.co.uk
to forward to
http://www.mydomain.com/blog/
as the "blog.mydomain.co.uk" is more popular (as it exists currently on a Google blog).
SOLUTION: We can either direct the "blog.mydomain.co.uk" subdomain to "mydomain.co.uk", and set up .htaccess on that .co.uk hosting account to redirect (301) to mydomain.com/blog/
OR
we can direct the "blog.mydomain.co.uk" subdomain to "mydomain.com" and set up the .htaccess on that sire to redirect as above.
Just wondering what you would choose? Is there any difference between the above, in terms of search engine optimisation? What's the 'better' way of doing it?
You shouldn't be paying for two accounts; you can have multiple domains pointing to the same server space, and handle the rewrites there. The best thing for SEO is to choose one as the primary domain and stick to it; that way you don't spread your web hits across multiple domains.
Neither of your solutions seem like completely the right answer. You're not really using mod_rewrite for it's power; you're just doing redirects (not internal rewrites), since you always do a 301, and you always provide a full URL (which implies a redirect, not a rewrite). There's no need to do the two-stage redirect you describe. Just redirect directly from the blog.mydomain.co.uk virtual host to mydomain.com/blog/, in one step.

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.