Reputation: 4017
Say example my domain is http://www.domain.com and i wanted to redirect into no-www url (http://domain.com), for that i used this code in .htaccess
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
It's working fine http://www.domain.com redirects to http://domain.com.
Now i have a sub-domain http://www.blog.domain.com (public_html/blog) to be redirected into no-www url http://blog.domain.com for that i used this code.
RewriteCond %{HTTP_HOST} !^blog\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://blog.domain.com$1 [R=301,L]
But then also www is not removing in the sub-domain url. What i am doing wrong here?
Update: My hosting provider is hostgator
Upvotes: 1
Views: 91
Reputation: 785491
Step 1:
It seems there is a WP .htaccess inside /public_html/blog
also. Add this rule before WP rules in your /public_html/blog/.htaccess:
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
Step 2:
Then in WP permalink settings
change your blog address to:
http://blog.domain.com
Upvotes: 1