301 redirects / htaccess - .htaccess

Could someone help me please with 301s. I'm moving a website to a new domain but it has a slightly different directory structure.
I've generated an .htaccess file with basic 301s, for example:
Redirect 301 /mypage1.html https://www.mywebsite.com/mypage/1/
Redirect 301 /mypage2.html https://www.mywebsite.com/mypage/2/
Redirect 301 /mypage3.html https://www.mywebsite.com/mypage/3/
This works perfectly. However, I cannot redirect the main homepage, as it seems to break all of my individual 301s.
So if I add:
Redirect 301 / https://www.mywebsite.com
All of my single 301 redirects stop working.
Is there any way I can keep the working 301s and also redirect the homepage too?

Related

Redirect few pages to new pages on new domain and the rest to the mainpage with .htaccess

I am trying to setup a redirection with .htaccess file.
So far I have this:
Redirect 301 /temat-konfiguracja-internetu-w-a2mobile https://infomobile.pl/konfiguracja-internetu-w-a2mobile-22500
Redirect 301 /temat-konfiguracja-mms-w-a2mobile https://infomobile.pl/konfiguracja-mms-w-a2mobile-22499
Redirect 301 /temat-jak-sprawdzic-stan-konta-w-a2mobile-oraz-inne-kody-ussd-w-a2mobile https://infomobile.pl/jak-sprawdzic-stan-konta-w-a2mobile-oraz-inne-kody-ussd-w-a2mobile-1812
Redirect 301 /temat-jak-sprawdzic-swoj-numer-telefonu-w-a2mobile https://infomobile.pl/jak-sprawdzic-swoj-numer-telefonu-w-a2mobile-22497
Redirect 301 /temat-konfiguracja-apn-internetu-i-mms-samsung-galaxy-s4 https://infomobile.pl/konfiguracja-apn-internetu-i-mms-samsung-galaxy-s4-11561
Redirect 301 /forum-internet-mobilny-w-a2mobile https://infomobile.pl/internet-mobilny-w-a2mobile-31
Redirect 301 /temat-ostrzegam-roaming-nie-dziala-w-a2mobile https://infomobile.pl/ostrzegam-roaming-nie-dziala-w-a2mobile-22494
Redirect 301 /temat-stan-konta-a2mobile https://infomobile.pl/stan-konta-a2mobile-22498
Redirect 301 /temat-rozwiązany-problem-z-konfiguracja-apn-na-urzadzeniu-meizu-m2-mini https://infomobile.pl/rozwiazany-problem-z-konfiguracja-apn-na-urzadzeniu-meizu-m2-mini-1817
Redirect 301 /temat-logowanie https://infomobile.pl/logowanie-761
Redirect 301 /mapa-index.xml https://infomobile.pl/sitemap/sitemap.xml
But... for all the other pages I want to setup a whole domain redirection (so for all the pages that are not on the list I want to point aero2forum.pl to infomobile.pl). Is there any way to accomplish this?
To redirect everything else to the root of the target domain you will need to add a (mod_alias) RedirectMatch directive after your existing (mod_alias) Redirect directives.
For example:
:
# Redirect everything else to the target domain's homepage
RedirectMatch 301 ^ https://example.target/
However, it should be noted, that from a search engine perspective, multiple redirects to the homepage will likely be seen as a soft-404. (And reported as such in Google Search Console.)
This does assume that the source and target domains point to different server's. Otherwise, this will naturally result in a redirect loop. You could avoid the redirect-loop by not redirecting the homepage, eg. ^/.. However, if both domains point to the same server then you will need to convert everything to use mod_rewrite instead and explicitly check the requested hostname.
Aside: You cannot use a (mod_rewrite) RewriteRule here since it will take priority over the existing Redirect directives (regardless of the order) and end up redirecting everything to the homepage of the target domain.

.htaccess Redirect 301 Strange behaviour

I have a new Website that consists of 1 Domain and 2 Subdomains:
Domain:
www.bluepuma.at
Subdomain:
werbeagentur.bluepuma.at
werbetechnik.bluepuma.at
The old website only had 1 Domain: www.bluepuma.at
Now I wrote a bunch of Redirects to redirect the old directorys from the old website to the new one:
I wrote them in the .htaccess which is in the root domain directory in www.bluepuma.at:
Redirect 301 /werbeagentur-bluepuma/wer-ist-bluepuma/ https://werbeagentur.bluepuma.at/
Redirect 301 /werbeagentur-bluepuma/jobs/ https://werbetechnik.bluepuma.at/werbetechnik/jobs-lienz
Redirect 301 /agentur/online-marketing/suchmaschinenoptimierung/ https://werbeagentur.bluepuma.at/online-werbung/online-marketing
Redirect 301 /agentur/online-marketing/suchmaschinenmarketing/ https://werbeagentur.bluepuma.at/online-werbung/online-marketing
Redirect 301 /agentur/online-marketing/social-media-marketing/ https://werbeagentur.bluepuma.at/online-werbung/social-media-marketing
Redirect 301 /agentur/online-marketing/newsletter-marketing/ https://werbeagentur.bluepuma.at/online-werbung/online-marketing
Redirect 301 /agentur/online-marketing/videomarketing/ https://werbeagentur.bluepuma.at/online-werbung/produktfotografie
Redirect 301 /agentur/online-marketing/analyse-controlling-reporting/ https://werbeagentur.bluepuma.at/online-werbung/online-marketing
Redirect 301 /agentur/online-marketing/marketing-konzepte-planung/ https://werbeagentur.bluepuma.at/online-werbung/online-marketing
Redirect 301 /agentur/online-marketing/ https://werbeagentur.bluepuma.at/online-werbung/online-
Now I have the problem, that the Redirect also work on the Subdomain:
Example:
If I open https://werbeagentur.bluepuma.at/werbeagentur-bluepuma/wer-ist-bluepuma/
I get redirected to https://werbeagentur.bluepuma.at/ according to this redirect statement:
Redirect 301 /werbeagentur-bluepuma/wer-ist-bluepuma/ https://werbeagentur.bluepuma.at/
But this should not be possible.
The Redirects should only affect the main domain. For example:
www.bluepuma.at/werbeagentur-bluepuma/wer-ist-bluepuma/ should get redirected to https://werbeagentur.bluepuma.at/
Do you have any ideas why this could be?
Another strange behaviour: If I open
www.bluepuma.at/agentur/online-marketing/suchmaschinenoptimierung/
I get to the page
https://werbeagentur.bluepuma.at/online-werbung/online-marketingsuchmaschinenoptimierung/
I have no idea what causes this error.
Thanks for your answer and your time!

301 redirects in .htaccess forming incorrect redirect

I'm trying to redirect http://brisbaneamazingrace.com.au/details.html to http://www.teambonding.com.au/activities/amazing-race-brisbane which is a different domain. In my .htaccess file I have
Redirect 301 http://brisbaneamazingrace.com.au/details.html http://www.teambonding.com.au/activities/amazing-race-brisbane
But the redirect goes to http://teambonding.com.au/activities/amazing-race-brisbanedetails.html
It keeps adding the details.html to the end of the redirect url. Whats up with that?
You should use RedirectMatch for regex matching:
RedirectMatxh 301 ^/details\.html$ http://www.teambonding.com.au/activities/amazing-race-brisbane
Also test this after clearing your browser cache.

how to create 301 redirection for all pages except robots.txt

I have just changed my domain mydomain.com to clientdomain.com. I have created 301 rediction useing
Redirect 301 / http://cleintdomain.com/
Everything works good. But I don't want to redirect http://mydomain.com/robots.txt. How can I exclude robots.txt from redirect condition?

Magento multiple 301 redirect with htaccess

I'm working on a project and stuck on a strange problem. i'm trying to 301 redirect multiple urls (1800+) to new url.
Redirect 301 /old.cfm http://www.mysite.com/folder/new.html
Its working fine for single url, but when I'm trying to add multiple 301 urls its not working.
example,
Redirect 301 /old.cfm http://www.mysite.com/folder/new.html
Redirect 301 /old2.cfm http://www.mysite.com/folder1/folder2/new.html
what is the problem with my code?
Rather use Admin > CataLog > URL Rewrite Management
Create a custom rewrite and set 'Redirect' to 301

Resources