• Hello, I’m trying to redirect the non www version of my site to the www version to prevent any duplicate issues but can’t seem to get it quite right.

    I have amended my .htaccess file with the following:

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

    This works to redirect the site but I end up with a load of trailing slashes at the end so it looks like this:

    https://www.mydomain.co.uk//

    I think it may be something to do with the WordPress permalink code but I’m not savvy enough with editing .htaccess to figure it out. Any ideas?

Viewing 1 replies (of 1 total)
  • Thread Starter topherknowles

    (@topherknowles)

    I managed to fix this by taking the trailing slash and $1 out of my above code:

    RewriteCond %{HTTP_HOST} ^mydomain.co.uk [NC]
    RewriteRule ^(.*)$ https://www.mydomain.co.uk [L,R=301]

    and removing the trailing slashes from other references to my domain in the .htaccess file

Viewing 1 replies (of 1 total)
  • The topic ‘Problems with non www to www redirect’ is closed to new replies.