Forums

Problems with non www to www redirect (2 posts)

  1. topherknowles
    Member
    Posted 3 months ago #

    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 ^(.*)$ http://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:

    http://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?

  2. topherknowles
    Member
    Posted 3 months ago #

    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 ^(.*)$ http://www.mydomain.co.uk [L,R=301]

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

Reply

You must log in to post.

About this Topic