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 http://www.url.com instead of to the post / page itself.
astereo:
Try this.
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.YOURDOMAIN.com$
RewriteRule ^(.*) http://www.YOURDOMAIN.com/$1 [QSA,L,R=301]
That should work.
It was still redirecting to the homepage...could it have to do with my permalink structure being /category/postname ?
I am still looking for a solution...
magicinthedesert
Member
Posted 2 years ago #
desertmagic
Member
Posted 2 years ago #
This is the code the worked for me:
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule (.*) http://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 (.*) http://www.domain.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress