I am trying to redirect the www domains to the non-www domains, as the www domains do not have a SSL Certificate, but the non-www's do. I have looked at the following questions
Generic htaccess redirect www to non-www
htaccess redirect from www to non-www
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
However the code provided (above) in the answers don't work wherever I put it. I am fairly inexperienced in htaccess so I don't know how to solve it.
The following is my current htaccess.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?sitename.com$ [OR]
RewriteCond %{HTTP_HOST} ^(www.)?sitename.co.uk$ [OR]
RewriteCond %{HTTP_HOST} ^(www.)?sitename.de$
RewriteCond %{REQUEST_URI} !^/wp/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /wp/$1
RewriteCond %{HTTP_HOST} ^(www.)?sitename.com$ [OR]
RewriteCond %{HTTP_HOST} ^(www.)?sitename.co.uk$ [OR]
RewriteCond %{HTTP_HOST} ^(www.)?sitename.de$
RewriteRule ^(/)?$ wp/index.php [L]
</IfModule>
Note: The above htaccess is working properly and redirecting accordingly in Google Chrome. However, Safari and Firefox output the following when addressing the www domain: