Forced www. and non www

Hi,

We have 5 sites within 1 multisite, all is fine however we have a bit of a quirk where we have css related issues with the www version of our site. So we want to force it to use the non-www address.

Any pointers and considerations before we go ahead and do this?

  • Gary
    • Design Lord, Child of Thor

    Hi

    Thanx, but the above doesn't work, this is my current .htacess file (before I added your code above):

    RewriteRule ^xmlrpc\.php$ "http\:\/\/0\.0\.0\.0\/" [R=301,L]
    RewriteRule ^wp-trackback\.php$ "http\:\/\/0\.0\.0\.0\/" [R=301,L]
    
    # BEGIN WordPress
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    
    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]
    
    # END WordPress
    <IfModule mod_headers.c>
    Header set Connection keep-alive
    </IfModule>
    RewriteCond %{HTTP_HOST} ^sanlambewell\.co\.za$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.sanlambewell\.co\.za$
  • Nastia
    • Support Rock Star

    Hello Gary , I hope you are doing well!

    Please delete the two last lines from the .htaccess file and place them at the top. If they will not work, you can also try adding the bellow rules:

    # Never use www in the domain
    # Replace 'example.com' with your domain name
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^www\.(([a-z0-9_]+\.)?example\.com)$ [NC]
    RewriteRule .? http://%1%{REQUEST_URI} [R=301,L]

    If the WordPress multisite is based in subdomain network try these rules:

    # Replace 'example.com' with your domain name
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} !^example.com$ [NC]
    RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

    Let me know how it went!

    Kind regards,
    Nastia

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.