htaccess experts: Redirect all but root to one TLD, redirect root to another TLD – WordPress

Help from the gurus is appreciated.

I have been requested to put a client’s WordPress homepage on one TLD (i.e. domain.eu), and have all other pages/directories be 301’d to a different TLD extension (i.e. domain.com/everything-else). Not sure why this is being requested, but apparently it’s important to the client, and I’ve been banging my head to get it working. Any ideas?

Read More

EXAMPLES:

If the URL hits any domain TLD’s roots, they should be redirected to the .eu domain (http://domain.eu/), but everything else should go to the .com domain (http://domain.com/)

Roots:

http://domain.com  OR
http://domain.net  OR
http://domain.edu/index.php OR
http://domain.org/index.html  OR
http://domain.* (* = any extension)

301 To: http://domain.eu

However, everything else needs to maintain the directory structure, and be redirected to the other TLD (http://domain.com). Examples..

From:

    http://domain.net/blog/category

301 To:

    http://domain.com/blog/category

From:

    http://domain.org/blog/category/post

301 To:

    http://domain.com/blog/category/post

Everything I’ve tried ends up in redirect loops or is only partially successful. For example, below is put above the WordPress redirects, and it redirects correctly in the sense that all the destination URL’s are hit, but the root (homepage) has a redirect loop error. Any thoughts?

RewriteEngine On
RewriteBase /
Options +FollowSymLinks

RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

RedirectMatch ^/$ http://domain.eu

RewriteCond %{REQUEST_URI} !^/$ [NC]
RewriteCond %{HTTP_HOST} ^domain.com.au$ [NC,OR]
RewriteCond %{HTTP_HOST} ^domain.eu$ [NC,OR]
RewriteCond %{HTTP_HOST} ^domain.de$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]

I’m a bit novice with htaccess, so let me know how I’m going about this wrong, thanks!

Related posts

Leave a Reply

2 comments

  1. WordPress will redirect any URLs that do not match the domain in the WordPress configuration. You’ll either need to write a WP plugin or use proxying to grab the homepage for the other domain.