Hello -FrA-,
You can just redirect the main domain to your subdomain(www).
I suggest you copy your .htaccess before inserting this new rule.
Note:Insert this new rule below “RewriteRule ^index\.php$ – [L]”
#redirect main domain to subdomain, just replace the domain
RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule (.*)$ http://www.domain.com/$1 [R=301,L]
Your .htaccess can be located at root folder of your wordpress install(this file is hidden by default).
Let me know if this helps!
Best Regards,
Calvin
Pssst Calvin. Use the CODE tags please 😉
Hello guys,
@ipstenu
Pssst Calvin. Use the CODE tags please 😉
Sorry, my bad. Will avoid it on the future replies. 🙂
Best Regards,
Calvin
Thread Starter
-fra-
(@fra-2)
Thank you Calvin, I’ve tried your suggestion, but anytime I try to reach http://domain.com I got redirected to http://www.domain.com/wp-signup.php?new=domain.com.
My htaccess already looks like this:
# -FrontPage-
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName domain.com
AuthUserFile /home/domain/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/domain/public_html/_vti_pvt/service.grp
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule (.*)$ http://www.domain.com/$1 [R=301,L]
</IfModule>
# END WordPress
Any Idea on how to fix this?
The issue is your server is trying to serve both www and non-www versions of domain.com
Put this at the TOP of your .htaccess
# Force the "www."
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
REMOVE this:
RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule (.*)$ http://www.domain.com/$1 [R=301,L]
Thread Starter
-fra-
(@fra-2)
Thank you! It works like a charm 🙂
FWIW, both my code and Calvin’s are the same. His said “If domain.com redirect to http://www.” Mind said “If NOT www, force http://WWW.”
Some servers are weirder than others, though Calvin’s should have worked if at the top of the .htaccess.
Remember! WordPress’ rules go on the bottom of your .htaccess file. Always.