16 Jan

WordPress Returns ‘Unknown Host’

I wanted to park one of my domains on top of another and use the canonical feature of WordPress to redirect the inbound link equity from the one domain to the other domain however when setup the second domain always returned ‘Unknown host: xxxx.com’.

I know if this is default behavior however I had so many plugins on this server it is often hard to tell what comes from WordPress core and what comes from plugins. As this is a live site I didn’t want to turn off all plugins until I found the one creating the issue.

My solution was to use a .htaccess 301 redirect from one hostname to the other. This redirect happens before WordPress gets involved so all WordPress sees is the domain it thinks its running on.

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.topsemtips\.com$
RewriteRule (.*) http://www.topsemtips.com/$1 [R=301,L]

This will redirect all requests to the domain www.topsemtips.com that do not use that as the host name (they might use topsemtips.com or xyz.com) to the same URL with the host name changed to www.topsemtips.com.

Leave a Reply

Your email address will not be published. Required fields are marked *