• I know how to do this with the by editing the htaccess, but how do you edit it to push non-www url to the www version but still go to the post page the user was trying to access? All the htaccess methods I’ve found just push an attempt at url.com/postname to https://www.url.com instead of to the post / page itself.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter astereo

    (@astereo)

    Anyone?

    astereo:

    Try this.

    Options +FollowSymlinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www.YOURDOMAIN.com$
    RewriteRule ^(.*) https://www.YOURDOMAIN.com/$1 [QSA,L,R=301]

    That should work.

    Thread Starter astereo

    (@astereo)

    It was still redirecting to the homepage…could it have to do with my permalink structure being /category/postname ?

    Thread Starter astereo

    (@astereo)

    ?

    Thread Starter astereo

    (@astereo)

    I am still looking for a solution…

    magicinthedesert

    (@magicinthedesert)

    desertmagic

    (@desertmagic)

    This is the code the worked for me:

    RewriteCond %{HTTP_HOST} ^domain\.com
    RewriteRule (.*) https://www.domain.com/$1 [R=301,L]

    Change the word ‘domain’ to your actual domain name for each line. I inserted into my the htaccess file, which already had some stuff in it. So the final code looked like this:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^domain\.com
    RewriteRule (.*) https://www.domain.com/$1 [R=301,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘SEO 301 Redirect’ is closed to new replies.