0
votes

Problem

I have a new TYPO3 website on a new domain. All important pages of the old website point to their new counterpart for which I added individual 301 redirects in the .htaccess. Those work fine!

However there are pages which have the exact same URL as the old website, which I cannot add individual redirects for (infinite loop). For example /contact/. When I access http://www.example-old.com/contact/ the page simply redirects to /index.php. Why?

Wishlist

  • All non-www should be redirected to www (works)
  • Other domains should be redirected to new (works)
  • Referrals from the old website, should be redirected to the same URL on the new domain, unless a manual 301 redirect is in place. (does not work)

Current setup

This is the .htacess snippet I'm working with:

<IfModule mod_rewrite.c>

# Enable URL rewriting

RewriteEngine On
RewriteBase /

# Point old domain to new domain

RewriteCond %{HTTP_HOST} ^example-old\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^example-new\.com$ [NC]
RewriteRule ^(.*) http://www.example-new.com/$1 [R=301,L]

# Point idle domains to new domain

RewriteCond %{HTTP_HOST} ^/?(?:www\.)?example-01.nl [OR]
RewriteCond %{HTTP_HOST} ^/?(?:www\.)?example-02.de [OR]
RewriteCond %{HTTP_HOST} ^/?(?:www\.)?example-03.eu [OR]
RewriteCond %{HTTP_HOST} ^/?(?:www\.)?example-04.net [OR]
RewriteCond %{HTTP_HOST} ^/?(?:www\.)?example-05.org
RewriteRule ^(.*)$ http://www.example-new.com/$1 [R=301,L]  

</IfModule>

I have tried every combination I could find to try and get this to work. What could be going wrong here?

Many Thanx!

2

2 Answers

0
votes

Try to remove the leading "/?" and the inner "?:" also escape the last dot from your http host conditions:

RewriteCond %{HTTP_HOST} ^(www\.)?example-01\.nl$ [OR]
RewriteCond %{HTTP_HOST} ^(www\.)?example-02\.de$ [OR]
RewriteCond %{HTTP_HOST} ^(www\.)?example-03\.eu$ [OR]
RewriteCond %{HTTP_HOST} ^(www\.)?example-04\.net$ [OR]
RewriteCond %{HTTP_HOST} ^(www\.)?example-05\.org$
RewriteRule ^(.*)$ http://www.example-new.com/$1 [R=301,L] 
0
votes

If you remove the ^ from the first RewriteCond all request to the old domain will be redirected to the new domain.

If you want the specific redirects to have priority make sure you put them before this one.

# Point old domain to new domain

RewriteCond %{HTTP_HOST} example-old\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^example-new\.com$ [NC]
RewriteRule ^(.*) http://www.example-new.com/$1 [R=301,L]