.htaccess redirects not working - .htaccess

We've setup a new website for www.immo-turkuaz.be on the domain www.turkuaz.be
In order to get through all the SEO value to the new domain, we've uploaded this .htaccess on www.immo-turkuaz.be
Redirect 301 / http://www.turkuaz.be
Redirect 301 /nl/tekoop.html http://www.turkuaz.be/nl/aanbod
Redirect 301 /nl/in-een-notendop.html http://www.turkuaz.be/nl/info/over-turkuaz/wie-zijn-we
Redirect 301 /nl/vastgoedinfo.html http://www.turkuaz.be/nl/info/infosessies
Redirect 301 /nl/vragen.html http://www.turkuaz.be/nl/info/faq
Redirect 301 /nl/index.html http://www.turkuaz.be/
Redirect 301 /nl/getuigenissen.html http://www.turkuaz.be/getuigenissen
Redirect 301 /nl/over-turkije.html http://www.turkuaz.be/nl/info/over-turkije
Redirect 301 /nl/regio.html http://www.turkuaz.be/nl/aanbod
Redirect 301 /nl/contact.html http://www.turkuaz.be/nl/contact
Redirect 301 /nl/projectbegeleiding.html http://www.turkuaz.be/nl/info/projectbegeleiding
Redirect 301 /nl/links.html http://www.turkuaz.be/nl/info/links
Redirect 301 /nl/detail/91/k2-deluxe-residence.html http://www.turkuaz.be/nl/aanbod/side/item/17-k2-deluxe-residence
Redirect 301 /nl/bezichtiging.html http://www.turkuaz.be/nl
Redirect 301 /nl/activiteiten.html http://www.turkuaz.be/nl/info/over-turkuaz/hoe-werken-we
Redirect 301 /nl/detail/86/zen.html http://www.turkuaz.be/nl/aanbod/side/item/24-naam-van-de-residentie
Redirect 301 /nl/detail/9/q-spa-resort.html http://www.turkuaz.be/nl/aanbod/side/item/23-q-spa-resort
Redirect 301 /nl/detail/34/city-highlights-ii.html http://www.turkuaz.be/nl/aanbod/dalaman-fethiye/item/22-city-highlights
Redirect 301 /nl/detail/14/the-hill.html http://www.turkuaz.be/nl/aanbod/side/item/21-the-hill-side
Redirect 301 /nl/detail/78/felicia-residence.html http://www.turkuaz.be/nl/aanbod/side/item/20-felicia-residence
Redirect 301 /nl/detail/35/orka-valley-spa---sport-complex.html http://www.turkuaz.be/nl/aanbod/dalaman-fethiye/item/19-orka-valley
Redirect 301 /nl/detail/22/the-valley.html http://www.turkuaz.be/nl/aanbod/side/item/18-the-valley
Redirect 301 /nl/detail/38/golden-heights-ii.html http://www.turkuaz.be/nl/aanbod/dalaman-fethiye/item/1-new-golden-heights
Redirect 301 /nl/detail/57/klaros-residence.html http://www.turkuaz.be/nl/
Redirect 301 /nl/detail/18/q-garden.html http://www.turkuaz.be/nl/aanbod/side/item/16-q-garden
Redirect 301 /nl/detail/56/sarigerme-heights.html http://www.turkuaz.be/nl/
Redirect 301 /nl/detail/17/majestica.html http://www.turkuaz.be/nl/aanbod/side/item/15-majestica
Redirect 301 /nl/detail/59/lakeshore-golf.html http://www.turkuaz.be/nl/aanbod/bodrum/item/14-lakeshore-golf
Redirect 301 /nl/detail/10/babylon.html http://www.turkuaz.be/nl/aanbod/side/item/13-babylon
Redirect 301 /nl/detail/15/agora.html http://www.turkuaz.be/nl/aanbod/side/item/12-agora-f11
Redirect 301 /nl/detail/16/citrus-garden.html http://www.turkuaz.be/nl/aanbod/side/item/11-citrus-garden
Redirect 301 /nl/detail/84/spring-3-appartement-a3.html http://www.turkuaz.be/nl/aanbod/side/item/9-spring-3-a3
Redirect 301 /nl/detail/82/royal-hills.html http://www.turkuaz.be/nl/aanbod/dalaman-fethiye/item/8-royal-hills
Redirect 301 /nl/detail/21/mandarin-garden.html http://www.turkuaz.be/nl/aanbod/side/item/7-mandarin-garden
Redirect 301 /nl/detail/23/tropicana.html http://www.turkuaz.be/nl/aanbod/side/item/6-tropicana
Redirect 301 /nl/detail/33/orka-park.html http://www.turkuaz.be/nl/aanbod/dalaman-fethiye/item/5-orka-park
Redirect 301 /nl/detail/25/sunset-residence.html http://www.turkuaz.be/nl
Redirect 301 /nl/detail/27/olive-grove.html http://www.turkuaz.be/nl/aanbod/side/item/4-olive-grove
Redirect 301 /nl/detail/29/okeanus.html http://www.turkuaz.be/nl/aanbod/side/item/3-okeanus
Redirect 301 /nl/detail/32/custom-build-villa.html http://www.turkuaz.be/nl/aanbod/side/item/2-custom-build-villa
Redirect 301 /nl/detail/42/uzumlu-mountain-villa.html http://www.turkuaz.be/nl/aanbod/dalaman-fethiye/item/41-oasis-uzumlu-villa
Redirect 301 /nl/detail/40/crown-villa.html http://www.turkuaz.be/nl/
Redirect 301 /nl/detail/41/orka-gardens.html http://www.turkuaz.be/nl/aanbod/dalaman-fethiye/item/40-orka-gardens
Redirect 301 /nl/detail/43/oasis-uzumlu-villa.html http://www.turkuaz.be/nl/aanbod/dalaman-fethiye/item/41-oasis-uzumlu-villa
Redirect 301 /nl/detail/52/centre-point-studio-s-en-appartementen.html http://www.turkuaz.be/nl/aanbod/dalaman-fethiye/item/42-centre-point
Redirect 301 /nl/detail/85/duplex-city-highlight-i.html http://www.turkuaz.be/nl/aanbod/dalaman-fethiye/item/43-duplex-city-highlight
Redirect 301 /nl/detail/53/olivia-apartments.html http://www.turkuaz.be/nl
Redirect 301 /nl/detail/54/olive-gold-villas.html http://www.turkuaz.be/nl/aanbod/dalaman-fethiye/item/44-olive-gold-villas
Redirect 301 /nl/detail/55/orka-diamond-collection.html http://www.turkuaz.be/nl/aanbod/dalaman-fethiye/item/54-diamond-collection
Now, this doesn't work as it should....
e.g.
www.immo-turkuaz.be/nl/tekoop.html redirects to www.turkuaz.be/nl/tekoop.html
While it should redirect to www.turkuaz.be/nl/aanbod (as you can see in the .htaccess content.
Only the homepage redirects well.
What am I doing wrong?

You might put the Homepage-Redirect to the most bottom of the list. Otherwise it will always redirect "/" and all containing files/folders first.

That is due to your very first rule:
Redirect 301 / http://www.turkuaz.be
Which is catching all the URLs and redirecting same to new host.
Move that line to the bottom of your .htaccess and retest after clearing your browser cache.

Related

.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!

Problem with path 301 redirects in htaccess

We're trying to redirect a bunch of category URLs like this:
Redirect 301 /table/ https://www.example.com/abc/
Redirect 301 /table/accessoires/ https://www.example.com/def/
Redirect 301 /table/accessoires/tablecloth/ https://www.example.com/ghj/
The first redirect works correctly. But why do the other 2 don't work?
Order matters. The more specific rules should be first.
Redirect 301 /table/accessoires/tablecloth/ https://www.example.com/ghj/
Redirect 301 /table/accessoires/ https://www.example.com/def
Redirect 301 /table/ https://www.example.com/abc/

301 Redirect just first Subfolder

I have a 301 Redirect from one page to another
REDIRECT 301 /cloud-computing /it-infrastructure/cloud-computing
Now when i use this redirect also the subpages of cloud-computing are affected by this 301 redirect, but they have to be redirected somewhere else. How can i just redirect the folder and not the subpages?
You should be using RedirectMatch for precise matching using regex:
RedirectMatch 301 ^/cloud-computing/?$ /it-infrastructure/cloud-computing
Clear your browser cache before testing the change.

301 Redirect not working in some cases

I've made a few changes to my URL structure. Here is my htaccess file
Redirect 301 /top100 http://www.example.com
Redirect 301 /monthlytop10 http://www.example.com/monthlytop
Redirect 301 /top100/Hardwell http://www.example.com/top100/hardwell
Redirect 301 /top100/Armin%20van%20Buuren http://www.example.com/top100/armin-van-buuren
Redirect 301 /top100/David%20Guetta http://www.example.com/top100/david-guetta
This works for the first 2 cases but doesn't work for the rest. It redirects www.example.com/top100/Armin%20van%20Buuren to www.example.com/Armin%20van%20Buuren
If I remove the first line in the htaccess file, it doesn't redirect at all and gives a 404 error. What's wrong here?
That is because Redirect directive doesn't support regex. Use RedirectMatch instead to match exactly what you want:
RedirectMatch 302 "^/top100/?$" /
RedirectMatch 302 "^/monthlytop10/?$" /monthlytop
RedirectMatch 302 "^/top100/Hardwell/?$" /top100/hardwell
RedirectMatch 302 "^/top100/Armin van Buuren/?$" /top100/armin-van-buuren
RedirectMatch 302 "^/top100/David Guetta/?$" /top100/david-guetta

redirect same sub by slash in htaccess

How to redirect as:
Redirect 301 /ruler/ http://www.sample.com/ruler/
Redirect 301 /ruler/red/review http://www.sample.com/product_review/flexible-ruler/
Redirect 301 /ruler/read/ http://www.sample.com/read/soft-ruler/
with above code, it not work correct. with
Redirect 301 /ruler/red/review will to http://www.sample.com/ruler/
Thanks about helps!
You need to put Redirect 301 /ruler/red/review line before Redirect 301 /ruler/, read more about Order of Processing

Resources